MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / set

Method set

Engine/source/gfx/genericConstBuffer.cpp:71–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71bool GenericConstBufferLayout::set(const ParamDesc& pd, const GFXShaderConstType constType, const U32 size, const void* data, U8* basePointer)
72{
73 PROFILE_SCOPE(GenericConstBufferLayout_set);
74
75 // Shader compilers like to optimize float4x4 uniforms into float3x3s.
76 // So long as the real paramater is a matrix of-some-type and the data
77 // passed in is a MatrixF ( which is will be ), we DO NOT have a
78 // mismatched const type.
79 AssertFatal( pd.constType == constType ||
80 (
81 ( pd.constType == GFXSCT_Float2x2 ||
82 pd.constType == GFXSCT_Float3x3 ||
83 pd.constType == GFXSCT_Float3x4 ||
84 pd.constType == GFXSCT_Float4x3 ||
85 pd.constType == GFXSCT_Float4x4 ) &&
86 ( constType == GFXSCT_Float2x2 ||
87 constType == GFXSCT_Float3x3 ||
88 constType == GFXSCT_Float3x4 ||
89 constType == GFXSCT_Float4x3 ||
90 constType == GFXSCT_Float4x4 )
91 ), "Mismatched const type!" );
92
93 // This "cute" bit of code allows us to support 2x3 and 3x3 matrices in shader constants but use our MatrixF class. Yes, a hack. -BTR
94 switch (pd.constType)
95 {
96 case GFXSCT_Float2x2 :
97 case GFXSCT_Float3x3 :
98 case GFXSCT_Float4x3 :
99 case GFXSCT_Float4x4 :
100 return setMatrix(pd, constType, size, data, basePointer);
101 break;
102 default :
103 break;
104 }
105
106 AssertFatal(pd.size >= size, "Not enough room in the buffer for this data!");
107
108 // Ok, we only set data if it's different than the data we already have, this maybe more expensive than just setting the data, but
109 // we'll have to do some timings to see. For example, the lighting shader constants rarely change, but we can't assume that at the
110 // renderInstMgr level, but we can check down here. -BTR
111 if (dMemcmp(basePointer+pd.offset, data, size) != 0)
112 {
113 dMemcpy(basePointer+pd.offset, data, size);
114 return true;
115 }
116 return false;
117}
118
119bool GenericConstBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderConstType constType, const U32 size, const void* data, U8* basePointer)
120{

Callers

nothing calls this directly

Calls 3

setMatrixFunction · 0.85
dMemcmpFunction · 0.50
dMemcpyFunction · 0.50

Tested by

no test coverage detected