wg_engine: avoid forced texture flushes

After introducing staged buffer removed the need for forced flush of each texture data into gpu
General approach used for all data types
Can increase performance on discrete GPUs
This commit is contained in:
Sergii Liebodkin 2025-06-13 10:57:39 +03:00 committed by Hermet Park
parent 39b0f87cb3
commit abfc5cc9e1
3 changed files with 8 additions and 2 deletions

View file

@ -85,7 +85,6 @@ bool WgContext::allocateTexture(WGPUTexture& texture, uint32_t width, uint32_t h
const WGPUTextureDataLayout textureDataLayout{ .bytesPerRow = 4 * width, .rowsPerImage = height };
const WGPUExtent3D writeSize{ .width = width, .height = height, .depthOrArrayLayers = 1 };
wgpuQueueWriteTexture(queue, &imageCopyTexture, data, 4 * width * height, &textureDataLayout, &writeSize);
wgpuQueueSubmit(queue, 0, nullptr);
} else {
releaseTexture(texture);
texture = createTexture(width, height, format);
@ -94,7 +93,6 @@ bool WgContext::allocateTexture(WGPUTexture& texture, uint32_t width, uint32_t h
const WGPUTextureDataLayout textureDataLayout{ .bytesPerRow = 4 * width, .rowsPerImage = height };
const WGPUExtent3D writeSize{ .width = width, .height = height, .depthOrArrayLayers = 1 };
wgpuQueueWriteTexture(queue, &imageCopyTexture, data, 4 * width * height, &textureDataLayout, &writeSize);
wgpuQueueSubmit(queue, 0, nullptr);
return true;
}
return false;
@ -287,6 +285,12 @@ void WgContext::releaseCommandEncoder(WGPUCommandEncoder& commandEncoder)
}
void WgContext::submit()
{
wgpuQueueSubmit(queue, 0, nullptr);
}
bool WgContext::invalid()
{
return !instance || !device;

View file

@ -73,6 +73,7 @@ struct WgContext {
void submitCommandEncoder(WGPUCommandEncoder encoder);
void releaseCommandEncoder(WGPUCommandEncoder& encoder);
void submit();
bool invalid();
};

View file

@ -201,6 +201,7 @@ void WgCompositor::flush(WgContext& context)
stageBufferGeometry.append(&meshDataBlit);
stageBufferGeometry.flush(context);
stageBufferPaint.flush(context);
context.submit();
}