Fix caching of dirty uniforms on GrD3DPipelineState.

Change-Id: Ibf68103e8e47d3cd13b12a97da3b9131dbdbfd38
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297857
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-06-19 15:22:18 -04:00 committed by Skia Commit-Bot
parent 579e63af00
commit a581a8b800
6 changed files with 24 additions and 1 deletions

View File

@ -49,6 +49,9 @@ public:
SK_ABORT("Only supported in NVPR, which is only available in GL");
}
// For the uniform data to be dirty so that we will reupload on the next use.
void markDirty() { fUniformsDirty = true; }
protected:
struct Uniform {
uint32_t fOffset;

View File

@ -126,6 +126,10 @@ bool GrD3DGpu::submitDirectCommandList(SyncQueue sync) {
return true;
}
// We just submitted the command list so make sure all GrD3DPipelineState's mark their cached
// uniform data as dirty.
fResourceProvider.markPipelineStateUniformsDirty();
new (fOutstandingCommandLists.push_back()) OutstandingCommandList(
std::move(fCurrentDirectCommandList), ++fCurrentFenceValue);

View File

@ -61,6 +61,11 @@ public:
void bindBuffers(GrD3DGpu*, const GrBuffer* indexBuffer, const GrBuffer* instanceBuffer,
const GrBuffer* vertexBuffer, GrD3DDirectCommandList* commandList);
// We can only cache non dirty uniform values until we submit a command list. After that, the
// next frame will get a completely different uniform buffer and/or offset into the buffer. Thus
// we need a way to mark them all as dirty during submit.
void markUniformsDirty() { fDataManager.markDirty(); }
private:
/**
* We use the RT's size and origin to adjust from Skia device space to d3d normalized device

View File

@ -33,7 +33,7 @@ GrD3DPipelineStateDataManager::GrD3DPipelineStateDataManager(const UniformInfoAr
D3D12_GPU_VIRTUAL_ADDRESS GrD3DPipelineStateDataManager::uploadConstants(GrD3DGpu* gpu) {
if (fUniformsDirty) {
fConstantBufferAddress = gpu->resourceProvider().uploadConstantData(fUniformData.get(),
fUniformSize);
fUniformSize);
fUniformsDirty = false;
}

View File

@ -252,3 +252,10 @@ sk_sp<GrD3DPipelineState> GrD3DResourceProvider::PipelineStateCache::refPipeline
}
return (*entry)->fPipelineState;
}
void GrD3DResourceProvider::PipelineStateCache::markPipelineStateUniformsDirty() {
fMap.foreach ([](const GrProgramDesc*, std::unique_ptr<Entry>* entry) {
(*entry)->fPipelineState->markUniformsDirty();
});
}

View File

@ -64,6 +64,8 @@ public:
D3D12_GPU_VIRTUAL_ADDRESS uploadConstantData(void* data, size_t size);
void prepForSubmit();
void markPipelineStateUniformsDirty() { fPipelineStateCache->markPipelineStateUniformsDirty(); }
#if GR_TEST_UTILS
void resetShaderCacheForTesting() const { fPipelineStateCache->release(); }
#endif
@ -81,6 +83,8 @@ private:
void release();
sk_sp<GrD3DPipelineState> refPipelineState(GrRenderTarget*, const GrProgramInfo&);
void markPipelineStateUniformsDirty();
private:
struct Entry;