22 , fCpuDescriptorManager(gpu)
23 , fDescriptorTableManager(gpu)
24 , fPipelineStateCache(new PipelineStateCache(gpu))
25 , fShaderResourceDescriptorTableCache(gpu)
26 , fSamplerDescriptorTableCache(gpu) {
32 fPipelineStateCache->release();
36 if (fAvailableDirectCommandLists.
size()) {
37 std::unique_ptr<GrD3DDirectCommandList> list =
38 std::move(fAvailableDirectCommandLists.
back());
39 fAvailableDirectCommandLists.
pop_back();
46 std::unique_ptr<GrD3DDirectCommandList> commandList) {
48 fAvailableDirectCommandLists.
push_back(std::move(commandList));
53 for (
int i = 0;
i < fRootSignatures.
size(); ++
i) {
54 if (fRootSignatures[
i]->isCompatible(numTextureSamplers, numUAVs)) {
55 return fRootSignatures[
i];
69 for (
int i = 0;
i < fCommandSignatures.
size(); ++
i) {
70 if (fCommandSignatures[
i]->isCompatible(indexed, slot)) {
71 return fCommandSignatures[
i];
84 ID3D12Resource* textureResource) {
94 ID3D12Resource* textureResource) {
104 ID3D12Resource* bufferResource,
size_t offset,
size_t size) {
109 ID3D12Resource*
resource,
unsigned int highestMip,
unsigned int mipLevels) {
114 ID3D12Resource*
resource,
unsigned int mipSlice) {
126 return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
128 return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
130 return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
132 return D3D12_TEXTURE_ADDRESS_MODE_BORDER;
139 return D3D12_FILTER_ANISOTROPIC;
145 switch (sampler.
filter()) {
151 switch (sampler.
filter()) {
165 D3D12_CPU_DESCRIPTOR_HANDLE* samplerPtr = fSamplers.
find(
key);
176 unsigned int maxAnisotropy =
params.maxAniso();
177 D3D12_CPU_DESCRIPTOR_HANDLE sampler =
179 fGpu, filter, maxLOD, maxAnisotropy, addressModeU, addressModeV).
fHandle;
180 fSamplers.
set(
key, sampler);
185 const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& shaderViews) {
187 auto createFunc = [
this](
GrD3DGpu* gpu,
unsigned int numDesc) {
190 return fShaderResourceDescriptorTableCache.findOrCreateDescTable(shaderViews, createFunc);
194 const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& samplers) {
195 auto createFunc = [
this](
GrD3DGpu* gpu,
unsigned int numDesc) {
198 return fShaderResourceDescriptorTableCache.findOrCreateDescTable(samplers, createFunc);
203 return fPipelineStateCache->refPipelineState(rt,
info);
207 if (!fMipmapPipeline) {
213 "SamplerState textureSampler : register(s0, space1);\n"
214 "Texture2D<float4> inputTexture : register(t1, space1);\n"
215 "RWTexture2D<float4> outUAV : register(u2, space1);\n"
217 "cbuffer UniformBuffer : register(b0, space0) {\n"
218 " float2 inverseDims;\n"
220 " uint sampleMode;\n"
223 "[numthreads(8, 8, 1)]\n"
224 "void main(uint groupIndex : SV_GroupIndex, uint3 threadID : SV_DispatchThreadID) {\n"
225 " float2 uv = inverseDims * (threadID.xy + 0.5);\n"
227 " switch (sampleMode) {\n"
229 " mipVal = inputTexture.SampleLevel(textureSampler, uv, mipLevel);\n"
233 " float2 uvdiff = inverseDims * 0.25;\n"
234 " mipVal = inputTexture.SampleLevel(textureSampler, uv-uvdiff, mipLevel);\n"
235 " mipVal += inputTexture.SampleLevel(textureSampler, uv+uvdiff, mipLevel);\n"
236 " uvdiff.y = -uvdiff.y;\n"
237 " mipVal += inputTexture.SampleLevel(textureSampler, uv-uvdiff, mipLevel);\n"
238 " mipVal += inputTexture.SampleLevel(textureSampler, uv+uvdiff, mipLevel);\n"
243 " float2 uvdiff = float2(inverseDims.x * 0.25, 0);\n"
244 " mipVal = inputTexture.SampleLevel(textureSampler, uv-uvdiff, mipLevel);\n"
245 " mipVal += inputTexture.SampleLevel(textureSampler, uv+uvdiff, mipLevel);\n"
250 " float2 uvdiff = float2(0, inverseDims.y * 0.25);\n"
251 " mipVal = inputTexture.SampleLevel(textureSampler, uv-uvdiff, mipLevel);\n"
252 " mipVal += inputTexture.SampleLevel(textureSampler, uv+uvdiff, mipLevel);\n"
258 " outUAV[threadID.xy] = mipVal;\n"
267 return fMipmapPipeline;
282 D3D12_GPU_VIRTUAL_ADDRESS gpuAddress = d3dBuffer->
d3dResource()->GetGPUVirtualAddress();
283 return gpuAddress + slice.
fOffset;
290 fShaderResourceDescriptorTableCache.release();
291 fSamplerDescriptorTableCache.release();
296#ifdef GR_PIPELINE_STATE_CACHE_STATS
298static const bool c_DisplayMtlPipelineCache{
false};
309GrD3DResourceProvider::PipelineStateCache::PipelineStateCache(
GrD3DGpu* gpu)
310 : fMap(gpu->getContext()->
priv().
options().fRuntimeProgramCacheSize)
312#ifdef GR_PIPELINE_STATE_CACHE_STATS
319GrD3DResourceProvider::PipelineStateCache::~PipelineStateCache() {
321#ifdef GR_PIPELINE_STATE_CACHE_STATS
322 if (c_DisplayMtlPipelineCache) {
323 SkDebugf(
"--- Pipeline State Cache ---\n");
324 SkDebugf(
"Total requests: %d\n", fTotalRequests);
325 SkDebugf(
"Cache misses: %d\n", fCacheMisses);
327 (fTotalRequests > 0) ? 100.f * fCacheMisses / fTotalRequests : 0.f);
328 SkDebugf(
"---------------------\n");
333void GrD3DResourceProvider::PipelineStateCache::release() {
339#ifdef GR_PIPELINE_STATE_CACHE_STATS
343 const GrCaps* caps = fGpu->caps();
346 if (!
desc.isValid()) {
347 GrCapsDebugf(fGpu->caps(),
"Failed to build mtl program descriptor!\n");
351 std::unique_ptr<Entry>* entry = fMap.find(
desc);
353#ifdef GR_PIPELINE_STATE_CACHE_STATS
356 std::unique_ptr<GrD3DPipelineState> pipelineState =
358 if (!pipelineState) {
361 entry = fMap.insert(
desc, std::unique_ptr<Entry>(
362 new Entry(fGpu, std::move(pipelineState))));
363 return ((*entry)->fPipelineState).get();
365 return ((*entry)->fPipelineState).get();
368void GrD3DResourceProvider::PipelineStateCache::markPipelineStateUniformsDirty() {
369 fMap.foreach ([](
const GrProgramDesc*, std::unique_ptr<Entry>* entry) {
370 (*entry)->fPipelineState->markUniformsDirty();
376void GrD3DResourceProvider::DescriptorTableCache::release() {
381 const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE>& cpuDescriptors,
388 unsigned int numDescriptors = cpuDescriptors.size();
389 SkASSERT(numDescriptors <= kRangeSizesCount);
391 fGpu->device()->CopyDescriptors(1, descTable->baseCpuDescriptorPtr(), &numDescriptors,
392 numDescriptors, cpuDescriptors.data(), fRangeSizes,
394 entry = fMap.insert(cpuDescriptors, std::move(descTable));
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
constexpr int kConstantAlignment
static D3D12_FILTER d3d_filter(GrSamplerState sampler)
static D3D12_TEXTURE_ADDRESS_MODE wrap_mode_to_d3d_address_mode(GrSamplerState::WrapMode wrapMode)
#define GrCapsDebugf(caps,...)
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
#define SK_ABORT(message,...)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkString resource(SkPDFResourceType type, int index)
virtual GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags overrideFlags=ProgramDescOverrideFlags::kNone) const =0
ID3D12Resource * d3dResource() const
static sk_sp< GrD3DCommandSignature > Make(GrD3DGpu *gpu, ForIndexed indexed, unsigned int slot)
GrD3DDescriptorHeap::CPUHandle createUnorderedAccessView(GrD3DGpu *, ID3D12Resource *resource, unsigned int mipSlice)
void recycleRenderTargetView(const GrD3DDescriptorHeap::CPUHandle &)
GrD3DDescriptorHeap::CPUHandle createShaderResourceView(GrD3DGpu *, ID3D12Resource *resource, unsigned int mostDetailedMip, unsigned int mipLevels)
GrD3DDescriptorHeap::CPUHandle createDepthStencilView(GrD3DGpu *, ID3D12Resource *textureResource)
GrD3DDescriptorHeap::CPUHandle createConstantBufferView(GrD3DGpu *, ID3D12Resource *bufferResource, size_t offset, size_t size)
GrD3DDescriptorHeap::CPUHandle createSampler(GrD3DGpu *, D3D12_FILTER filter, float maxLOD, unsigned int maxAnisotropy, D3D12_TEXTURE_ADDRESS_MODE addressModeU, D3D12_TEXTURE_ADDRESS_MODE addressModeV)
void recycleDepthStencilView(const GrD3DDescriptorHeap::CPUHandle &)
void recycleShaderView(const GrD3DDescriptorHeap::CPUHandle &)
GrD3DDescriptorHeap::CPUHandle createRenderTargetView(GrD3DGpu *, ID3D12Resource *textureResource)
sk_sp< GrD3DDescriptorTable > createShaderViewTable(GrD3DGpu *, unsigned int count)
void prepForSubmit(GrD3DGpu *gpu)
sk_sp< GrD3DDescriptorTable > createSamplerTable(GrD3DGpu *, unsigned int count)
static std::unique_ptr< GrD3DDirectCommandList > Make(GrD3DGpu *gpu)
GrRingBuffer * uniformsRingBuffer() override
static sk_sp< GrD3DPipeline > MakeComputePipeline(GrD3DGpu *, GrD3DRootSignature *, const char *shader)
static std::unique_ptr< GrD3DPipelineState > MakePipelineState(GrD3DGpu *, GrD3DRenderTarget *, const GrProgramDesc &, const GrProgramInfo &)
void recycleDirectCommandList(std::unique_ptr< GrD3DDirectCommandList >)
GrD3DDescriptorHeap::CPUHandle createUnorderedAccessView(ID3D12Resource *resource, unsigned int mipSlice)
void recycleShaderView(const GrD3DDescriptorHeap::CPUHandle &)
GrD3DDescriptorHeap::CPUHandle createDepthStencilView(ID3D12Resource *textureResource)
GrD3DResourceProvider(GrD3DGpu *)
sk_sp< GrD3DCommandSignature > findOrCreateCommandSignature(GrD3DCommandSignature::ForIndexed, unsigned int slot)
GrD3DDescriptorHeap::CPUHandle createShaderResourceView(ID3D12Resource *resource, unsigned int mostDetailedMip=0, unsigned int mipLevels=-1)
D3D12_GPU_VIRTUAL_ADDRESS uploadConstantData(void *data, size_t size)
sk_sp< GrD3DDescriptorTable > findOrCreateShaderViewTable(const std::vector< D3D12_CPU_DESCRIPTOR_HANDLE > &shaderViews)
GrD3DDescriptorHeap::CPUHandle createRenderTargetView(ID3D12Resource *textureResource)
D3D12_CPU_DESCRIPTOR_HANDLE findOrCreateCompatibleSampler(const GrSamplerState ¶ms)
GrD3DDescriptorHeap::CPUHandle createConstantBufferView(ID3D12Resource *bufferResource, size_t offset, size_t size)
void recycleRenderTargetView(const GrD3DDescriptorHeap::CPUHandle &)
sk_sp< GrD3DPipeline > findOrCreateMipmapPipeline()
std::unique_ptr< GrD3DDirectCommandList > findOrCreateDirectCommandList()
sk_sp< GrD3DDescriptorTable > findOrCreateSamplerTable(const std::vector< D3D12_CPU_DESCRIPTOR_HANDLE > &samplers)
void recycleDepthStencilView(const GrD3DDescriptorHeap::CPUHandle &)
GrD3DPipelineState * findOrCreateCompatiblePipelineState(GrD3DRenderTarget *, const GrProgramInfo &)
sk_sp< GrD3DRootSignature > findOrCreateRootSignature(int numTextureSamplers, int numUAVs=0)
static sk_sp< GrD3DRootSignature > Make(GrD3DGpu *gpu, int numTextureSamplers, int numUAVs)
Slice suballocate(size_t size)
constexpr Filter filter() const
constexpr MipmapMode mipmapMode() const
V * find(const K &key) const
const EmbeddedViewParams * params
FlPixelBufferTexturePrivate * priv
Dart_NativeFunction function
static float max(float r, float g, float b)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
D3D12_CPU_DESCRIPTOR_HANDLE fHandle
std::unique_ptr< GrD3DPipelineState > fPipelineState
Entry(GrD3DGpu *gpu, std::unique_ptr< GrD3DPipelineState > pipelineState)
std::shared_ptr< const fml::Mapping > data