MCPcopy Create free account
hub / github.com/carbonengine/trinity / FillAndSetConstants

Function FillAndSetConstants

trinity/Tr2RenderUtils.cpp:102–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, const void* const data, const size_t dataSize, unsigned constantTypeMask, const unsigned registerIndex, Tr2RenderContext& renderContext )
103{
104 if( constantTypeMask == 0 )
105 {
106 return true;
107 }
108 if( !buffer.IsValid() || dataSize > buffer.GetSize() )
109 {
110 USE_MAIN_THREAD_RENDER_CONTEXT();
111 CR_RETURN_VAL( buffer.Create( (unsigned int)dataSize, renderContext ), false );
112 }
113
114 void* mapped = nullptr;
115 if( !SUCCEEDED( buffer.Lock( &mapped, renderContext ) ) || !mapped )
116 {
117 return false;
118 }
119
120 memcpy( mapped, data, std::min( (uint32_t)dataSize, buffer.GetSize() ) );
121 buffer.Unlock( renderContext );
122
123 SetConstants( buffer, constantTypeMask, registerIndex, renderContext );
124
125 return true;
126}
127
128void SetConstants( Tr2ConstantBufferAL& buffer, unsigned constantTypeMask, const unsigned registerIndex, Tr2RenderContext& renderContext )
129{

Callers

nothing calls this directly

Calls 6

SetConstantsFunction · 0.70
IsValidMethod · 0.45
GetSizeMethod · 0.45
CreateMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected