Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
WrapShaderBindings.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2026 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
6
7 // First WrapShaderBegin.h should have been included, then the shader code
8
10 virtual void Bind(const char *inName, void *inData, uint64 inSize) override
11 {
12 // Don't redefine constants
13 #undef JPH_SHADER_CONSTANT
14 #define JPH_SHADER_CONSTANT(type, name, value)
15
16 // Don't redefine structs
17 #undef JPH_SHADER_STRUCT_BEGIN
18 #undef JPH_SHADER_STRUCT_MEMBER
19 #undef JPH_SHADER_STRUCT_END
20 #define JPH_SHADER_STRUCT_BEGIN(name)
21 #define JPH_SHADER_STRUCT_MEMBER(type, name)
22 #define JPH_SHADER_STRUCT_END(name)
23
24 // When a constant buffer is bound, copy the data into the members
25 #undef JPH_SHADER_CONSTANTS_BEGIN
26 #undef JPH_SHADER_CONSTANTS_MEMBER
27 #define JPH_SHADER_CONSTANTS_BEGIN(type, name) case HashString(#name): memcpy(&name + 1, inData, size_t(inSize)); break; // Very hacky way to get the address of the first constant and to copy the entire block of constants
28 #define JPH_SHADER_CONSTANTS_MEMBER(type, name)
29
30 // When a buffer is bound, set the pointer
31 #undef JPH_SHADER_BIND_BUFFER
32 #undef JPH_SHADER_BIND_RW_BUFFER
33 #define JPH_SHADER_BIND_BUFFER(type, name) case HashString(#name): name = (const type *)inData; break;
34 #define JPH_SHADER_BIND_RW_BUFFER(type, name) case HashString(#name): name = (type *)inData; break;
35
36 switch (HashString(inName))
37 {
38 // Now include the shader bindings followed by WrapShaderEnd.h
39
std::uint64_t uint64
Definition Core.h:504
constexpr uint64 HashString(const char *inString, uint64 inSeed=0xcbf29ce484222325UL)
Definition HashCombine.h:28