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

Method FillUPVertexBuffer

trinityal/Tr2DrawUPHelper.cpp:66–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66ALResult Tr2DrawUPHelper::FillUPVertexBuffer(
67 uint32_t vertexCount,
68 const void* vertexStreamZeroData,
69 uint32_t vertexStreamZeroStride,
70 ::Tr2BufferAL& buffer,
71 Tr2RenderContextAL& renderContext,
72 Tr2PrimaryRenderContextAL& device )
73{
74 const uint32_t totalSize = vertexCount * vertexStreamZeroStride;
75
76 if( totalSize == 0 )
77 {
78 return S_OK;
79 }
80
81 if( totalSize > buffer.GetDesc().count * buffer.GetDesc().stride )
82 {
83 CR_RETURN_HR( buffer.Create( 4, ( totalSize + 3 ) / 4, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, device ) );
84 }
85
86 void* mapped = nullptr;
87 CR_RETURN_HR( buffer.MapForWriting( mapped, renderContext ) );
88 if( !mapped )
89 {
90 buffer.UnmapForWriting( renderContext );
91 return E_FAIL;
92 }
93 memcpy( mapped, vertexStreamZeroData, totalSize );
94 buffer.UnmapForWriting( renderContext );
95
96 return S_OK;
97}
98
99ALResult Tr2DrawUPHelper::DrawPrimitiveUP(
100 Tr2RenderContextEnum::Topology topology,

Callers

nothing calls this directly

Calls 3

CreateMethod · 0.45
MapForWritingMethod · 0.45
UnmapForWritingMethod · 0.45

Tested by

no test coverage detected