Rename D3D descriptor methods to be clearer

Change-Id: I047c4397fba87ce5db6f422162f942ac0ca0b0b9
Bug: skia:10446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395816
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2021-04-12 16:38:52 -04:00 committed by Skia Commit-Bot
parent 2a650cc795
commit 3473b4e724
8 changed files with 31 additions and 29 deletions

View File

@ -12,7 +12,7 @@
GrD3DCpuDescriptorManager::GrD3DCpuDescriptorManager(GrD3DGpu* gpu)
: fRTVDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_RTV)
, fDSVDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_DSV)
, fCBVSRVUAVDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
, fShaderViewDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
, fSamplerDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) {}
GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createRenderTargetView(
@ -41,7 +41,8 @@ void GrD3DCpuDescriptorManager::recycleDepthStencilView(
GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createConstantBufferView(
GrD3DGpu* gpu, ID3D12Resource* bufferResource, size_t offset, size_t size) {
const GrD3DDescriptorHeap::CPUHandle& descriptor = fCBVSRVUAVDescriptorPool.allocateHandle(gpu);
const GrD3DDescriptorHeap::CPUHandle& descriptor =
fShaderViewDescriptorPool.allocateHandle(gpu);
D3D12_CONSTANT_BUFFER_VIEW_DESC desc = {};
desc.BufferLocation = bufferResource->GetGPUVirtualAddress() + offset;
desc.SizeInBytes = size;
@ -51,7 +52,8 @@ GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createConstantBufferVi
GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createShaderResourceView(
GrD3DGpu* gpu, ID3D12Resource* resource) {
const GrD3DDescriptorHeap::CPUHandle& descriptor = fCBVSRVUAVDescriptorPool.allocateHandle(gpu);
const GrD3DDescriptorHeap::CPUHandle& descriptor =
fShaderViewDescriptorPool.allocateHandle(gpu);
// TODO: for 4:2:0 YUV formats we'll need to map two different views, one for Y and one for UV.
// For now map the entire resource.
gpu->device()->CreateShaderResourceView(resource, nullptr, descriptor.fHandle);
@ -60,15 +62,16 @@ GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createShaderResourceVi
GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createUnorderedAccessView(
GrD3DGpu* gpu, ID3D12Resource* resource) {
const GrD3DDescriptorHeap::CPUHandle& descriptor = fCBVSRVUAVDescriptorPool.allocateHandle(gpu);
const GrD3DDescriptorHeap::CPUHandle& descriptor =
fShaderViewDescriptorPool.allocateHandle(gpu);
// TODO: might need more granularity here for textures (specify miplevels, etc.)
gpu->device()->CreateUnorderedAccessView(resource, nullptr, nullptr, descriptor.fHandle);
return descriptor;
}
void GrD3DCpuDescriptorManager::recycleCBVSRVUAV(
void GrD3DCpuDescriptorManager::recycleShaderView(
const GrD3DDescriptorHeap::CPUHandle& view) {
fCBVSRVUAVDescriptorPool.releaseHandle(view);
fShaderViewDescriptorPool.releaseHandle(view);
}
GrD3DDescriptorHeap::CPUHandle GrD3DCpuDescriptorManager::createSampler(

View File

@ -32,7 +32,7 @@ public:
ID3D12Resource* resource);
GrD3DDescriptorHeap::CPUHandle createUnorderedAccessView(GrD3DGpu*,
ID3D12Resource* resource);
void recycleCBVSRVUAV(const GrD3DDescriptorHeap::CPUHandle&);
void recycleShaderView(const GrD3DDescriptorHeap::CPUHandle&);
GrD3DDescriptorHeap::CPUHandle createSampler(GrD3DGpu*,
D3D12_FILTER filter,
@ -85,7 +85,7 @@ private:
HeapPool fRTVDescriptorPool;
HeapPool fDSVDescriptorPool;
HeapPool fCBVSRVUAVDescriptorPool;
HeapPool fShaderViewDescriptorPool;
HeapPool fSamplerDescriptorPool;
};

View File

@ -10,13 +10,13 @@
#include "src/gpu/d3d/GrD3DGpu.h"
GrD3DDescriptorTableManager::GrD3DDescriptorTableManager(GrD3DGpu* gpu)
: fCBVSRVUAVDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
: fShaderViewDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
, fSamplerDescriptorPool(gpu, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) {}
sk_sp<GrD3DDescriptorTable>
GrD3DDescriptorTableManager::createCBVSRVUAVTable(GrD3DGpu* gpu,
GrD3DDescriptorTableManager::createShaderViewTable(GrD3DGpu* gpu,
unsigned int size) {
sk_sp<GrD3DDescriptorTable> table = fCBVSRVUAVDescriptorPool.allocateTable(gpu, size);
sk_sp<GrD3DDescriptorTable> table = fShaderViewDescriptorPool.allocateTable(gpu, size);
this->setHeaps(gpu);
return table;
}
@ -29,7 +29,7 @@ sk_sp<GrD3DDescriptorTable> GrD3DDescriptorTableManager::createSamplerTable(
}
void GrD3DDescriptorTableManager::setHeaps(GrD3DGpu* gpu) {
sk_sp<Heap>& currentCBVSRVHeap = fCBVSRVUAVDescriptorPool.currentDescriptorHeap();
sk_sp<Heap>& currentCBVSRVHeap = fShaderViewDescriptorPool.currentDescriptorHeap();
sk_sp<Heap>& currentSamplerHeap = fSamplerDescriptorPool.currentDescriptorHeap();
GrD3DDirectCommandList* commandList = gpu->currentCommandList();
commandList->setDescriptorHeaps(currentCBVSRVHeap,
@ -39,7 +39,7 @@ void GrD3DDescriptorTableManager::setHeaps(GrD3DGpu* gpu) {
}
void GrD3DDescriptorTableManager::prepForSubmit(GrD3DGpu* gpu) {
fCBVSRVUAVDescriptorPool.prepForSubmit(gpu);
fShaderViewDescriptorPool.prepForSubmit(gpu);
fSamplerDescriptorPool.prepForSubmit(gpu);
}
@ -50,7 +50,7 @@ void GrD3DDescriptorTableManager::recycle(Heap* heap) {
SkASSERT(heap);
switch (heap->type()) {
case D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV:
fCBVSRVUAVDescriptorPool.recycle(std::move(wrappedHeap));
fShaderViewDescriptorPool.recycle(std::move(wrappedHeap));
break;
case D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER:
fSamplerDescriptorPool.recycle(std::move(wrappedHeap));

View File

@ -42,7 +42,7 @@ class GrD3DDescriptorTableManager {
public:
GrD3DDescriptorTableManager(GrD3DGpu*);
sk_sp<GrD3DDescriptorTable> createCBVSRVUAVTable(GrD3DGpu*, unsigned int count);
sk_sp<GrD3DDescriptorTable> createShaderViewTable(GrD3DGpu*, unsigned int count);
sk_sp<GrD3DDescriptorTable> createSamplerTable(GrD3DGpu*, unsigned int count);
void prepForSubmit(GrD3DGpu* gpu);
@ -115,7 +115,7 @@ private:
void setHeaps(GrD3DGpu*);
void recycle(Heap*);
HeapPool fCBVSRVUAVDescriptorPool;
HeapPool fShaderViewDescriptorPool;
HeapPool fSamplerDescriptorPool;
};

View File

@ -132,7 +132,7 @@ void GrD3DPipelineState::setAndBindTextures(GrD3DGpu* gpu,
if (fNumSamplers > 0) {
// set up and bind shader resource view table
sk_sp<GrD3DDescriptorTable> srvTable =
gpu->resourceProvider().findOrCreateShaderResourceTable(shaderResourceViews);
gpu->resourceProvider().findOrCreateShaderViewTable(shaderResourceViews);
gpu->currentCommandList()->setGraphicsRootDescriptorTable(
static_cast<unsigned int>(GrD3DRootSignature::ParamIndex::kTextureDescriptorTable),
srvTable->baseGpuDescriptor());

View File

@ -114,9 +114,9 @@ GrD3DDescriptorHeap::CPUHandle GrD3DResourceProvider::createUnorderedAccessView(
return fCpuDescriptorManager.createUnorderedAccessView(fGpu, resource);
}
void GrD3DResourceProvider::recycleCBVSRVUAV(
void GrD3DResourceProvider::recycleShaderView(
const GrD3DDescriptorHeap::CPUHandle& view) {
fCpuDescriptorManager.recycleCBVSRVUAV(view);
fCpuDescriptorManager.recycleShaderView(view);
}
static D3D12_TEXTURE_ADDRESS_MODE wrap_mode_to_d3d_address_mode(GrSamplerState::WrapMode wrapMode) {
@ -175,14 +175,13 @@ D3D12_CPU_DESCRIPTOR_HANDLE GrD3DResourceProvider::findOrCreateCompatibleSampler
return sampler;
}
sk_sp<GrD3DDescriptorTable> GrD3DResourceProvider::findOrCreateShaderResourceTable(
const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& shaderResourceViews) {
sk_sp<GrD3DDescriptorTable> GrD3DResourceProvider::findOrCreateShaderViewTable(
const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& shaderViews) {
auto createFunc = [this](GrD3DGpu* gpu, unsigned int numDesc) {
return this->fDescriptorTableManager.createCBVSRVUAVTable(gpu, numDesc);
return this->fDescriptorTableManager.createShaderViewTable(gpu, numDesc);
};
return fShaderResourceDescriptorTableCache.findOrCreateDescTable(shaderResourceViews,
createFunc);
return fShaderResourceDescriptorTableCache.findOrCreateDescTable(shaderViews, createFunc);
}
sk_sp<GrD3DDescriptorTable> GrD3DResourceProvider::findOrCreateSamplerTable(

View File

@ -55,12 +55,12 @@ public:
size_t size);
GrD3DDescriptorHeap::CPUHandle createShaderResourceView(ID3D12Resource* resource);
GrD3DDescriptorHeap::CPUHandle createUnorderedAccessView(ID3D12Resource* resource);
void recycleCBVSRVUAV(const GrD3DDescriptorHeap::CPUHandle&);
void recycleShaderView(const GrD3DDescriptorHeap::CPUHandle&);
D3D12_CPU_DESCRIPTOR_HANDLE findOrCreateCompatibleSampler(const GrSamplerState& params);
sk_sp<GrD3DDescriptorTable> findOrCreateShaderResourceTable(
const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& shaderResourceViews);
sk_sp<GrD3DDescriptorTable> findOrCreateShaderViewTable(
const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& shaderViews);
sk_sp<GrD3DDescriptorTable> findOrCreateSamplerTable(
const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& samplers);
GrD3DDescriptorTableManager* descriptorTableMgr() {

View File

@ -110,7 +110,7 @@ sk_sp<GrD3DTexture> GrD3DTexture::MakeWrappedTexture(GrD3DGpu* gpu,
void GrD3DTexture::onRelease() {
GrD3DGpu* gpu = this->getD3DGpu();
gpu->resourceProvider().recycleCBVSRVUAV(fShaderResourceView);
gpu->resourceProvider().recycleShaderView(fShaderResourceView);
this->releaseResource(gpu);
INHERITED::onRelease();
@ -118,7 +118,7 @@ void GrD3DTexture::onRelease() {
void GrD3DTexture::onAbandon() {
GrD3DGpu* gpu = this->getD3DGpu();
gpu->resourceProvider().recycleCBVSRVUAV(fShaderResourceView);
gpu->resourceProvider().recycleShaderView(fShaderResourceView);
this->releaseResource(gpu);
INHERITED::onAbandon();
}