MCPcopy Create free account
hub / github.com/defold/defold / SetNamedConstant

Function SetNamedConstant

engine/render/src/render/constant.cpp:271–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void SetNamedConstant(HNamedConstantBuffer buffer, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values, dmRenderDDF::MaterialDesc::ConstantType type)
272{
273 dmHashTable64<NamedConstantBuffer::Constant>& constants = buffer->m_Constants;
274
275 NamedConstantBuffer::Constant* c = constants.Get(name_hash);
276 if (c && c->m_NumValues != num_values)
277 {
278 RemoveNamedConstant(buffer, name_hash);
279 c = 0;
280 }
281
282 if (c == 0)
283 {
284 if (constants.Full())
285 {
286 uint32_t capacity = constants.Capacity() + 8;
287 constants.SetCapacity(capacity, capacity * 2);
288 }
289
290 if (buffer->m_Values.Remaining() < num_values)
291 buffer->m_Values.OffsetCapacity(num_values - buffer->m_Values.Remaining());
292
293 uint32_t values_index = buffer->m_Values.Size();
294
295 buffer->m_Values.SetSize(buffer->m_Values.Size() + num_values);
296
297 NamedConstantBuffer::Constant constant;
298 constant.m_NameHash = name_hash;
299 constant.m_NumValues = num_values;
300 constant.m_ValueIndex = values_index;
301 constant.m_Type = type;
302 constants.Put(name_hash, constant);
303
304 // Get the pointer
305 c = constants.Get(name_hash);
306 }
307
308 dmVMath::Vector4* p = &buffer->m_Values[c->m_ValueIndex];
309 memcpy(p, values, sizeof(values[0]) * num_values);
310}
311
312void SetNamedConstant(HNamedConstantBuffer buffer, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values)
313{

Callers 6

TESTFunction · 0.85
TEST_FFunction · 0.85
SetNamedConstantsFunction · 0.85
CreateFontRenderBatchFunction · 0.85
ApplyMorphToRenderObjectFunction · 0.85
SetRenderConstantsFunction · 0.85

Calls 10

RemoveNamedConstantFunction · 0.85
GetMethod · 0.45
FullMethod · 0.45
CapacityMethod · 0.45
SetCapacityMethod · 0.45
RemainingMethod · 0.45
OffsetCapacityMethod · 0.45
SizeMethod · 0.45
SetSizeMethod · 0.45
PutMethod · 0.45

Tested by 2

TESTFunction · 0.68
TEST_FFunction · 0.68