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

Class Tr2PersistentPerObjectData

trinity/Tr2PersistentPerObjectData.h:21–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19// --------------------------------------------------------------------------------------
20template <typename Owner>
21class Tr2PersistentPerObjectData
22 : public Tr2DeviceResource
23{
24public:
25 Tr2PersistentPerObjectData() :
26 m_bufferDirty( true )
27 {
28 }
29
30 // ----------------------------------------------------------------------------------
31 // Description:
32 // Invalidates dirty flag for the object. Next time it is requested to apply its
33 // constant buffer, the object fill re-fill it with new data.
34 // ----------------------------------------------------------------------------------
35 void InvalidateBufferData()
36 {
37 m_bufferDirty = true;
38 }
39
40 void UpdateBuffer( Owner& owner, Tr2RenderContextEnum::ShaderType shaderType )
41 {
42#if TRINITY_PLATFORM != TRINITY_DIRECTX11
43 if( !m_bufferDirty )
44 {
45 return;
46 }
47 uint32_t size = owner.GetPerObjectDataSize( shaderType );
48 if( size > 0 )
49 {
50 USE_MAIN_THREAD_RENDER_CONTEXT();
51
52 auto& buffer = m_constantBuffer;
53 if( !buffer.IsValid() || size > buffer.GetSize() )
54 {
55 CR_RETURN( buffer.Create( size, renderContext.GetPrimaryRenderContext() ) );
56 }
57 void* data = nullptr;
58
59 if( SUCCEEDED( buffer.Lock( &data, renderContext ) ) && data )
60 {
61 owner.UpdatePerObjectBuffer( shaderType, size, data );
62 buffer.Unlock( renderContext );
63 }
64 }
65 m_bufferDirty = false;
66#endif
67 }
68
69 Tr2ConstantBufferAL& UpdateBuffer(
70 Owner& owner,
71 Tr2RenderContextEnum::ShaderType shaderType,
72 Tr2RenderContext& renderContext )
73 {
74 if( m_bufferDirty )
75 {
76 uint32_t size = owner.GetPerObjectDataSize( shaderType );
77 if( size > 0 )
78 {

Callers

nothing calls this directly

Calls 7

GetPerObjectDataSizeMethod · 0.45
IsValidMethod · 0.45
GetSizeMethod · 0.45
CreateMethod · 0.45
LockMethod · 0.45
UpdatePerObjectBufferMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected