MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CreateStaging

Method CreateStaging

GTE/Graphics/GL46/GL46TextureSingle.cpp:288–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void GL46TextureSingle::CreateStaging()
289{
290 auto texture = GetTexture();
291 auto const copyType = texture->GetCopy();
292
293 auto const createPixelUnpackBuffers =
294 (copyType == Resource::Copy::CPU_TO_STAGING) ||
295 (copyType == Resource::Copy::BIDIRECTIONAL);
296
297 auto const createPixelPackBuffers =
298 (copyType == Resource::Copy::STAGING_TO_CPU) ||
299 (copyType == Resource::Copy::BIDIRECTIONAL);
300
301 // TODO: Determine frequency and nature of usage for this staging buffer
302 // when created by calling glBufferData.
303 GLenum usage = GL_DYNAMIC_DRAW;
304
305 if (createPixelUnpackBuffers)
306 {
307 for (int32_t level = 0; level < mNumLevels; ++level)
308 {
309 auto& pixBuffer = mLevelPixelUnpackBuffer[level];
310 if (0 == pixBuffer)
311 {
312 auto numBytes = texture->GetNumBytesFor(level);
313
314 // Create pixel buffer for staging.
315 glGenBuffers(1, &pixBuffer);
316 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixBuffer);
317 glBufferData(GL_PIXEL_UNPACK_BUFFER, numBytes, 0, usage);
318 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
319 }
320 }
321 }
322
323 if (createPixelPackBuffers)
324 {
325 for (int32_t level = 0; level < mNumLevels; ++level)
326 {
327 auto& pixBuffer = mLevelPixelPackBuffer[level];
328 if (0 == pixBuffer)
329 {
330 auto numBytes = texture->GetNumBytesFor(level);
331
332 // Create pixel buffer for staging.
333 glGenBuffers(1, &pixBuffer);
334 glBindBuffer(GL_PIXEL_PACK_BUFFER, pixBuffer);
335 glBufferData(GL_PIXEL_PACK_BUFFER, numBytes, 0, usage);
336 glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
337 }
338 }
339 }
340}
341
342

Callers

nothing calls this directly

Calls 5

glGenBuffersFunction · 0.85
glBindBufferFunction · 0.85
glBufferDataFunction · 0.85
GetNumBytesForMethod · 0.80
GetCopyMethod · 0.45

Tested by

no test coverage detected