mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-19 14:31:39 +00:00
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:
parent
39b0f87cb3
commit
abfc5cc9e1
3 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -73,6 +73,7 @@ struct WgContext {
|
|||
void submitCommandEncoder(WGPUCommandEncoder encoder);
|
||||
void releaseCommandEncoder(WGPUCommandEncoder& encoder);
|
||||
|
||||
void submit();
|
||||
bool invalid();
|
||||
};
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ void WgCompositor::flush(WgContext& context)
|
|||
stageBufferGeometry.append(&meshDataBlit);
|
||||
stageBufferGeometry.flush(context);
|
||||
stageBufferPaint.flush(context);
|
||||
context.submit();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue