Flutter Engine
The Flutter Engine
Functions
GrD3DOpsRenderPass.cpp File Reference
#include "src/gpu/ganesh/d3d/GrD3DOpsRenderPass.h"
#include "src/gpu/ganesh/GrBackendUtils.h"
#include "src/gpu/ganesh/GrOpFlushState.h"
#include "src/gpu/ganesh/GrProgramDesc.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrStencilSettings.h"
#include "src/gpu/ganesh/d3d/GrD3DBuffer.h"
#include "src/gpu/ganesh/d3d/GrD3DCommandSignature.h"
#include "src/gpu/ganesh/d3d/GrD3DGpu.h"
#include "src/gpu/ganesh/d3d/GrD3DPipelineState.h"
#include "src/gpu/ganesh/d3d/GrD3DPipelineStateBuilder.h"
#include "src/gpu/ganesh/d3d/GrD3DRenderTarget.h"
#include "src/gpu/ganesh/d3d/GrD3DTexture.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"

Go to the source code of this file.

Functions

void set_stencil_ref (GrD3DGpu *gpu, const GrProgramInfo &info)
 
void set_blend_factor (GrD3DGpu *gpu, const GrProgramInfo &info)
 
void set_primitive_topology (GrD3DGpu *gpu, const GrProgramInfo &info)
 
void set_scissor_rects (GrD3DGpu *gpu, const GrRenderTarget *renderTarget, GrSurfaceOrigin rtOrigin, const SkIRect &scissorRect)
 
void set_viewport (GrD3DGpu *gpu, const GrRenderTarget *renderTarget)
 
void update_resource_state (GrTexture *tex, GrRenderTarget *rt, GrD3DGpu *gpu)
 
static D3D12_RECT scissor_to_d3d_clear_rect (const GrScissorState &scissor, const GrSurface *surface, GrSurfaceOrigin origin)
 

Function Documentation

◆ scissor_to_d3d_clear_rect()

static D3D12_RECT scissor_to_d3d_clear_rect ( const GrScissorState scissor,
const GrSurface surface,
GrSurfaceOrigin  origin 
)
static

Definition at line 293 of file GrD3DOpsRenderPass.cpp.

295 {
296 D3D12_RECT clearRect;
297 // Flip rect if necessary
298 SkIRect d3dRect;
299 if (!scissor.enabled()) {
300 d3dRect.setXYWH(0, 0, surface->width(), surface->height());
301 } else if (kBottomLeft_GrSurfaceOrigin != origin) {
302 d3dRect = scissor.rect();
303 } else {
304 d3dRect.setLTRB(scissor.rect().fLeft, surface->height() - scissor.rect().fBottom,
305 scissor.rect().fRight, surface->height() - scissor.rect().fTop);
306 }
307 clearRect.left = d3dRect.fLeft;
308 clearRect.right = d3dRect.fRight;
309 clearRect.top = d3dRect.fTop;
310 clearRect.bottom = d3dRect.fBottom;
311 return clearRect;
312}
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
bool enabled() const
const SkIRect & rect() const
VkSurfaceKHR surface
Definition: main.cc:49
Definition: SkRect.h:32
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
Definition: SkRect.h:268
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition: SkRect.h:253
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35

◆ set_blend_factor()

void set_blend_factor ( GrD3DGpu gpu,
const GrProgramInfo info 
)

Definition at line 96 of file GrD3DOpsRenderPass.cpp.

96 {
97 const GrXferProcessor& xferProcessor = info.pipeline().getXferProcessor();
98 const skgpu::Swizzle& swizzle = info.pipeline().writeSwizzle();
99 const skgpu::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
100 skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
101 skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
102 float floatColors[4];
104 // Swizzle the blend to match what the shader will output.
105 SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
106 floatColors[0] = blendConst.fR;
107 floatColors[1] = blendConst.fG;
108 floatColors[2] = blendConst.fB;
109 floatColors[3] = blendConst.fA;
110 } else {
111 memset(floatColors, 0, 4 * sizeof(float));
112 }
113 gpu->currentCommandList()->setBlendFactor(floatColors);
114}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
void setBlendFactor(const float blendFactor[4])
GrD3DDirectCommandList * currentCommandList() const
Definition: GrD3DGpu.h:48
skgpu::BlendInfo getBlendInfo() const
constexpr std::array< float, 4 > applyTo(std::array< float, 4 > color) const
Definition: Swizzle.h:101
static constexpr bool BlendCoeffRefsConstant(const BlendCoeff coeff)
Definition: Blend.h:141
BlendCoeff
Definition: Blend.h:60
float fB
blue component
Definition: SkColor.h:265
float fR
red component
Definition: SkColor.h:263
float fG
green component
Definition: SkColor.h:264
float fA
alpha component
Definition: SkColor.h:266
skgpu::BlendCoeff fDstBlend
Definition: Blend.h:96
SkPMColor4f fBlendConstant
Definition: Blend.h:97
skgpu::BlendCoeff fSrcBlend
Definition: Blend.h:95

◆ set_primitive_topology()

void set_primitive_topology ( GrD3DGpu gpu,
const GrProgramInfo info 
)

Definition at line 116 of file GrD3DOpsRenderPass.cpp.

116 {
117 D3D12_PRIMITIVE_TOPOLOGY topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
118 switch (info.primitiveType()) {
120 topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
121 break;
123 topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
124 break;
126 topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
127 break;
129 topology = D3D_PRIMITIVE_TOPOLOGY_LINELIST;
130 break;
132 topology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
133 break;
134 default:
136 }
138}
#define SkUNREACHABLE
Definition: SkAssert.h:135
void setPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY primitiveTopology)

◆ set_scissor_rects()

void set_scissor_rects ( GrD3DGpu gpu,
const GrRenderTarget renderTarget,
GrSurfaceOrigin  rtOrigin,
const SkIRect scissorRect 
)

Definition at line 140 of file GrD3DOpsRenderPass.cpp.

141 {
142 SkASSERT(scissorRect.isEmpty() ||
143 SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).contains(scissorRect));
144
145 D3D12_RECT scissor;
146 scissor.left = scissorRect.fLeft;
147 scissor.right = scissorRect.fRight;
148 if (kTopLeft_GrSurfaceOrigin == rtOrigin) {
149 scissor.top = scissorRect.fTop;
150 } else {
152 scissor.top = renderTarget->height() - scissorRect.fBottom;
153 }
154 scissor.bottom = scissor.top + scissorRect.height();
155
156 SkASSERT(scissor.left >= 0);
157 SkASSERT(scissor.top >= 0);
158 gpu->currentCommandList()->setScissorRects(1, &scissor);
159}
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
#define SkASSERT(cond)
Definition: SkAssert.h:116
void setScissorRects(unsigned int numRects, const D3D12_RECT *rects)
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
constexpr int32_t height() const
Definition: SkRect.h:165
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
bool isEmpty() const
Definition: SkRect.h:202
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ set_stencil_ref()

void set_stencil_ref ( GrD3DGpu gpu,
const GrProgramInfo info 
)

Definition at line 81 of file GrD3DOpsRenderPass.cpp.

81 {
82 GrStencilSettings stencilSettings = info.nonGLStencilSettings();
83 if (!stencilSettings.isDisabled()) {
84 unsigned int stencilRef = 0;
85 if (stencilSettings.isTwoSided()) {
86 SkASSERT(stencilSettings.postOriginCCWFace(info.origin()).fRef ==
87 stencilSettings.postOriginCWFace(info.origin()).fRef);
88 stencilRef = stencilSettings.postOriginCCWFace(info.origin()).fRef;
89 } else {
90 stencilRef = stencilSettings.singleSidedFace().fRef;
91 }
92 gpu->currentCommandList()->setStencilRef(stencilRef);
93 }
94}
void setStencilRef(unsigned int stencilRef)
bool isTwoSided() const
const Face & postOriginCCWFace(GrSurfaceOrigin origin) const
bool isDisabled() const
const Face & singleSidedFace() const
const Face & postOriginCWFace(GrSurfaceOrigin origin) const

◆ set_viewport()

void set_viewport ( GrD3DGpu gpu,
const GrRenderTarget renderTarget 
)

Definition at line 161 of file GrD3DOpsRenderPass.cpp.

161 {
162 D3D12_VIEWPORT viewport;
163 viewport.TopLeftX = 0.0f;
164 viewport.TopLeftY = 0.0f;
165 viewport.Width = SkIntToScalar(renderTarget->width());
166 viewport.Height = SkIntToScalar(renderTarget->height());
167 viewport.MinDepth = 0.0f;
168 viewport.MaxDepth = 1.0f;
169 gpu->currentCommandList()->setViewports(1, &viewport);
170}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void setViewports(unsigned int numViewports, const D3D12_VIEWPORT *viewports)

◆ update_resource_state()

void update_resource_state ( GrTexture tex,
GrRenderTarget rt,
GrD3DGpu gpu 
)

Definition at line 212 of file GrD3DOpsRenderPass.cpp.

212 {
213 SkASSERT(!tex->isProtected() || (rt->isProtected() && gpu->protectedContext()));
214 GrD3DTexture* d3dTex = static_cast<GrD3DTexture*>(tex);
215 SkASSERT(d3dTex);
216 d3dTex->setResourceState(gpu, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
217}
bool protectedContext() const
Definition: GrD3DGpu.h:55
void setResourceState(const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState, unsigned int subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
bool isProtected() const
Definition: GrSurface.h:87