Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | List of all members
GrD3DPipelineState Class Reference

#include <GrD3DPipelineState.h>

Public Types

using UniformInfoArray = GrD3DPipelineStateDataManager::UniformInfoArray
 

Public Member Functions

 GrD3DPipelineState (sk_sp< GrD3DPipeline > pipeline, sk_sp< GrD3DRootSignature > rootSignature, const GrGLSLBuiltinUniformHandles &builtinUniformHandles, const UniformInfoArray &uniforms, uint32_t uniformSize, uint32_t numSamplers, std::unique_ptr< GrGeometryProcessor::ProgramImpl > gpImpl, std::unique_ptr< GrXferProcessor::ProgramImpl > xpImpl, std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fpImpls, size_t vertexStride, size_t instanceStride)
 
const sk_sp< GrD3DPipeline > & pipeline () const
 
const sk_sp< GrD3DRootSignature > & rootSignature () const
 
void setAndBindConstants (GrD3DGpu *, const GrRenderTarget *, const GrProgramInfo &)
 
void setAndBindTextures (GrD3DGpu *, const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &)
 
void bindBuffers (GrD3DGpu *, sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrD3DDirectCommandList *commandList)
 
void markUniformsDirty ()
 

Detailed Description

Definition at line 27 of file GrD3DPipelineState.h.

Member Typedef Documentation

◆ UniformInfoArray

Definition at line 29 of file GrD3DPipelineState.h.

Constructor & Destructor Documentation

◆ GrD3DPipelineState()

GrD3DPipelineState::GrD3DPipelineState ( sk_sp< GrD3DPipeline pipeline,
sk_sp< GrD3DRootSignature rootSignature,
const GrGLSLBuiltinUniformHandles builtinUniformHandles,
const UniformInfoArray uniforms,
uint32_t  uniformSize,
uint32_t  numSamplers,
std::unique_ptr< GrGeometryProcessor::ProgramImpl gpImpl,
std::unique_ptr< GrXferProcessor::ProgramImpl xpImpl,
std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > >  fpImpls,
size_t  vertexStride,
size_t  instanceStride 
)

Definition at line 24 of file GrD3DPipelineState.cpp.

36 : fPipeline(std::move(pipeline))
37 , fRootSignature(std::move(rootSignature))
38 , fBuiltinUniformHandles(builtinUniformHandles)
39 , fGPImpl(std::move(gpImpl))
40 , fXPImpl(std::move(xpImpl))
41 , fFPImpls(std::move(fpImpls))
42 , fDataManager(uniforms, uniformSize)
43 , fNumSamplers(numSamplers)
44 , fVertexStride(vertexStride)
45 , fInstanceStride(instanceStride) {}
const sk_sp< GrD3DPipeline > & pipeline() const
const sk_sp< GrD3DRootSignature > & rootSignature() const

Member Function Documentation

◆ bindBuffers()

void GrD3DPipelineState::bindBuffers ( GrD3DGpu gpu,
sk_sp< const GrBuffer indexBuffer,
sk_sp< const GrBuffer instanceBuffer,
sk_sp< const GrBuffer vertexBuffer,
GrD3DDirectCommandList commandList 
)

Definition at line 154 of file GrD3DPipelineState.cpp.

157 {
158 // Here our vertex and instance inputs need to match the same 0-based bindings they were
159 // assigned in the PipelineState. That is, vertex first (if any) followed by instance.
160 if (vertexBuffer) {
161 auto* d3dVertexBuffer = static_cast<const GrD3DBuffer*>(vertexBuffer.get());
162 SkASSERT(!d3dVertexBuffer->isCpuBuffer());
163 SkASSERT(!d3dVertexBuffer->isMapped());
164 const_cast<GrD3DBuffer*>(d3dVertexBuffer)->setResourceState(
165 gpu, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
166 }
167 if (instanceBuffer) {
168 auto* d3dInstanceBuffer = static_cast<const GrD3DBuffer*>(instanceBuffer.get());
169 SkASSERT(!d3dInstanceBuffer->isCpuBuffer());
170 SkASSERT(!d3dInstanceBuffer->isMapped());
171 const_cast<GrD3DBuffer*>(d3dInstanceBuffer)->setResourceState(
172 gpu, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
173 }
174 commandList->setVertexBuffers(0, std::move(vertexBuffer), fVertexStride,
175 std::move(instanceBuffer), fInstanceStride);
176
177 if (auto* d3dIndexBuffer = static_cast<const GrD3DBuffer*>(indexBuffer.get())) {
178 SkASSERT(!d3dIndexBuffer->isCpuBuffer());
179 SkASSERT(!d3dIndexBuffer->isMapped());
180 const_cast<GrD3DBuffer*>(d3dIndexBuffer)->setResourceState(
181 gpu, D3D12_RESOURCE_STATE_INDEX_BUFFER);
182 commandList->setIndexBuffer(std::move(indexBuffer));
183 }
184}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void setVertexBuffers(unsigned int startSlot, sk_sp< const GrBuffer > vertexBuffer, size_t vertexStride, sk_sp< const GrBuffer > instanceBuffer, size_t instanceStride)
void setIndexBuffer(sk_sp< const GrBuffer > indexBuffer)
T * get() const
Definition: SkRefCnt.h:303

◆ markUniformsDirty()

void GrD3DPipelineState::markUniformsDirty ( )
inline

Definition at line 60 of file GrD3DPipelineState.h.

60{ fDataManager.markDirty(); }

◆ pipeline()

const sk_sp< GrD3DPipeline > & GrD3DPipelineState::pipeline ( ) const
inline

Definition at line 43 of file GrD3DPipelineState.h.

43{ return fPipeline; }

◆ rootSignature()

const sk_sp< GrD3DRootSignature > & GrD3DPipelineState::rootSignature ( ) const
inline

Definition at line 44 of file GrD3DPipelineState.h.

44{ return fRootSignature; }

◆ setAndBindConstants()

void GrD3DPipelineState::setAndBindConstants ( GrD3DGpu gpu,
const GrRenderTarget renderTarget,
const GrProgramInfo programInfo 
)

Definition at line 47 of file GrD3DPipelineState.cpp.

49 {
50 this->setRenderTargetState(renderTarget, programInfo.origin());
51
52 fGPImpl->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc());
53
54 for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
55 const auto& fp = programInfo.pipeline().getFragmentProcessor(i);
56 fp.visitWithImpls([&](const GrFragmentProcessor& fp,
58 impl.setData(fDataManager, fp);
59 }, *fFPImpls[i]);
60 }
61
62 programInfo.pipeline().setDstTextureUniforms(fDataManager, &fBuiltinUniformHandles);
63 fXPImpl->setData(fDataManager, programInfo.pipeline().getXferProcessor());
64
65 D3D12_GPU_VIRTUAL_ADDRESS constantsAddress = fDataManager.uploadConstants(gpu);
68 constantsAddress);
69}
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
void setGraphicsRootConstantBufferView(unsigned int rootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS bufferLocation)
GrD3DDirectCommandList * currentCommandList() const
Definition: GrD3DGpu.h:48
D3D12_GPU_VIRTUAL_ADDRESS uploadConstants(GrD3DGpu *gpu)
void setData(const GrGLSLProgramDataManager &pdman, const GrFragmentProcessor &processor)
const GrCaps * caps() const
Definition: GrGpu.h:73
void setDstTextureUniforms(const GrGLSLProgramDataManager &pdm, GrGLSLBuiltinUniformHandles *fBuiltinUniformHandles) const
Definition: GrPipeline.cpp:115
const GrFragmentProcessor & getFragmentProcessor(int idx) const
Definition: GrPipeline.h:157
const GrXferProcessor & getXferProcessor() const
Definition: GrPipeline.h:116
GrSurfaceOrigin origin() const
Definition: GrProgramInfo.h:38
const GrPipeline & pipeline() const
Definition: GrProgramInfo.h:39
const GrGeometryProcessor & geomProc() const
Definition: GrProgramInfo.h:40
const uint32_t fp

◆ setAndBindTextures()

void GrD3DPipelineState::setAndBindTextures ( GrD3DGpu gpu,
const GrGeometryProcessor geomProc,
const GrSurfaceProxy *const  geomProcTextures[],
const GrPipeline pipeline 
)

Definition at line 94 of file GrD3DPipelineState.cpp.

97 {
98 SkASSERT(geomProcTextures || !geomProc.numTextureSamplers());
99
100 std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> shaderResourceViews(fNumSamplers);
101 std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> samplers(fNumSamplers);
102 unsigned int currTextureBinding = 0;
103
104 for (int i = 0; i < geomProc.numTextureSamplers(); ++i) {
105 SkASSERT(geomProcTextures[i]->asTextureProxy());
106 const auto& sampler = geomProc.textureSampler(i);
107 auto texture = static_cast<GrD3DTexture*>(geomProcTextures[i]->peekTexture());
108 shaderResourceViews[currTextureBinding] = texture->shaderResourceView();
109 samplers[currTextureBinding++] =
110 gpu->resourceProvider().findOrCreateCompatibleSampler(sampler.samplerState());
112 }
113
114 if (GrTexture* dstTexture = pipeline.peekDstTexture()) {
115 auto texture = static_cast<GrD3DTexture*>(dstTexture);
116 shaderResourceViews[currTextureBinding] = texture->shaderResourceView();
117 samplers[currTextureBinding++] = gpu->resourceProvider().findOrCreateCompatibleSampler(
120 }
121
122 pipeline.visitTextureEffects([&](const GrTextureEffect& te) {
123 GrSamplerState samplerState = te.samplerState();
124 auto* texture = static_cast<GrD3DTexture*>(te.texture());
125 shaderResourceViews[currTextureBinding] = texture->shaderResourceView();
126 samplers[currTextureBinding++] =
129 });
130
131 SkASSERT(fNumSamplers == currTextureBinding);
132
133 // fill in descriptor tables and bind to root signature
134 if (fNumSamplers > 0) {
135 // set up descriptor tables and bind heaps
137 gpu->resourceProvider().findOrCreateShaderViewTable(shaderResourceViews);
138 sk_sp<GrD3DDescriptorTable> samplerTable =
140 gpu->currentCommandList()->setDescriptorHeaps(srvTable->heap(), samplerTable->heap());
141
142 // bind shader resource view table
145 srvTable->baseGpuDescriptor());
146
147 // bind sampler table
150 samplerTable->baseGpuDescriptor());
151 }
152}
void addSampledTextureRef(GrD3DTexture *)
void setDescriptorHeaps(ID3D12DescriptorHeap *srvDescriptorHeap, ID3D12DescriptorHeap *samplerDescriptorHeap)
void setGraphicsRootDescriptorTable(unsigned int rootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE bufferLocation)
GrD3DResourceProvider & resourceProvider()
Definition: GrD3DGpu.h:38
sk_sp< GrD3DDescriptorTable > findOrCreateShaderViewTable(const std::vector< D3D12_CPU_DESCRIPTOR_HANDLE > &shaderViews)
D3D12_CPU_DESCRIPTOR_HANDLE findOrCreateCompatibleSampler(const GrSamplerState &params)
sk_sp< GrD3DDescriptorTable > findOrCreateSamplerTable(const std::vector< D3D12_CPU_DESCRIPTOR_HANDLE > &samplers)
const TextureSampler & textureSampler(int index) const
GrTexture * peekTexture() const
GrTexture * texture() const
GrSamplerState samplerState() const
FlTexture * texture

The documentation for this class was generated from the following files: