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

Method CreateBuffer

trinity/Tr2GpuBuffer.cpp:142–177  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Re-creates AL buffer. Return Value: true If AL buffer is successfully created false Otherwise --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

140// false Otherwise
141// --------------------------------------------------------------------------------------
142ALResult Tr2GpuBuffer::CreateBuffer()
143{
144 m_buffer = Tr2BufferAL();
145 if( !m_count || m_format == PIXEL_FORMAT_UNKNOWN )
146 {
147 return E_INVALIDARG;
148 }
149 auto gpuUsage = Tr2GpuUsage::SHADER_RESOURCE;
150 auto cpuUsage = Tr2CpuUsage::READ;
151 if( m_creationFlags & GPU_WRITABLE )
152 {
153 gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS;
154 }
155 else if( m_creationFlags & CPU_WRITABLE )
156 {
157 cpuUsage = cpuUsage | Tr2CpuUsage::WRITE;
158 }
159 if( m_creationFlags & DRAW_INDIRECT )
160 {
161 gpuUsage = gpuUsage | Tr2GpuUsage::DRAW_INDIRECT_ARGS;
162 }
163
164 USE_MAIN_THREAD_RENDER_CONTEXT();
165 auto hr = m_buffer.Create(
166 static_cast<PixelFormat>( m_format ),
167 m_count,
168 gpuUsage,
169 cpuUsage,
170 nullptr,
171 renderContext );
172 if( !m_name.empty() && SUCCEEDED( hr ) )
173 {
174 m_buffer.SetName( m_name.c_str() );
175 }
176 return hr;
177}
178
179void Tr2GpuBuffer::ReleaseResources( TriStorage )
180{

Callers 3

CreateMethod · 0.45
CreateStagingBufferMethod · 0.45
CreateMethod · 0.45

Calls 4

emptyMethod · 0.80
Tr2BufferALClass · 0.50
CreateMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected