MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / GraphicsStateObject

Method GraphicsStateObject

Source/Falcor/Core/API/GraphicsStateObject.cpp:235–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235GraphicsStateObject::GraphicsStateObject(ref<Device> pDevice, const GraphicsStateObjectDesc& desc) : mpDevice(pDevice), mDesc(desc)
236{
237 if (spDefaultBlendState == nullptr)
238 {
239 // Create default objects
240 spDefaultBlendState = BlendState::create(BlendState::Desc());
241 spDefaultDepthStencilState = DepthStencilState::create(DepthStencilState::Desc());
242 spDefaultRasterizerState = RasterizerState::create(RasterizerState::Desc());
243 }
244
245 // Initialize default objects
246 if (!mDesc.pBlendState)
247 mDesc.pBlendState = spDefaultBlendState;
248 if (!mDesc.pRasterizerState)
249 mDesc.pRasterizerState = spDefaultRasterizerState;
250 if (!mDesc.pDepthStencilState)
251 mDesc.pDepthStencilState = spDefaultDepthStencilState;
252
253 gfx::GraphicsPipelineStateDesc gfxDesc = {};
254 // Set blend state.
255 const auto& blendState = mDesc.pBlendState;
256 FALCOR_ASSERT(blendState->getRtCount() <= gfx::kMaxRenderTargetCount);
257 auto& targetBlendDescs = gfxDesc.blend.targets;
258 {
259 gfxDesc.blend.targetCount = blendState->getRtCount();
260 for (gfx::UInt i = 0; i < gfxDesc.blend.targetCount; ++i)
261 {
262 auto& rtDesc = blendState->getRtDesc(i);
263 auto& gfxRtDesc = targetBlendDescs[i];
264 gfxRtDesc.enableBlend = rtDesc.blendEnabled;
265
266 gfxRtDesc.alpha.dstFactor = getGFXBlendFactor(rtDesc.dstAlphaFunc);
267 gfxRtDesc.alpha.srcFactor = getGFXBlendFactor(rtDesc.srcAlphaFunc);
268 gfxRtDesc.alpha.op = getGFXBlendOp(rtDesc.alphaBlendOp);
269
270 gfxRtDesc.color.dstFactor = getGFXBlendFactor(rtDesc.dstRgbFunc);
271 gfxRtDesc.color.srcFactor = getGFXBlendFactor(rtDesc.srcRgbFunc);
272 gfxRtDesc.color.op = getGFXBlendOp(rtDesc.rgbBlendOp);
273
274 targetBlendDescs[i].writeMask = gfx::RenderTargetWriteMask::EnableNone;
275 if (rtDesc.writeMask.writeAlpha)
276 gfxRtDesc.writeMask |= gfx::RenderTargetWriteMask::EnableAlpha;
277 if (rtDesc.writeMask.writeBlue)
278 gfxRtDesc.writeMask |= gfx::RenderTargetWriteMask::EnableBlue;
279 if (rtDesc.writeMask.writeGreen)
280 gfxRtDesc.writeMask |= gfx::RenderTargetWriteMask::EnableGreen;
281 if (rtDesc.writeMask.writeRed)
282 gfxRtDesc.writeMask |= gfx::RenderTargetWriteMask::EnableRed;
283 }
284 }
285
286 // Set depth stencil state.
287 {
288 const auto& depthStencilState = mDesc.pDepthStencilState;
289 getGFXStencilDesc(gfxDesc.depthStencil.backFace, depthStencilState->getStencilDesc(Falcor::DepthStencilState::Face::Back));
290 getGFXStencilDesc(gfxDesc.depthStencil.frontFace, depthStencilState->getStencilDesc(Falcor::DepthStencilState::Face::Front));
291 gfxDesc.depthStencil.depthFunc = getGFXComparisonFunc(depthStencilState->getDepthFunc());
292 gfxDesc.depthStencil.depthTestEnable = depthStencilState->isDepthTestEnabled();

Callers

nothing calls this directly

Calls 15

getGFXBlendFactorFunction · 0.85
getGFXBlendOpFunction · 0.85
getGFXStencilDescFunction · 0.85
getGFXComparisonFuncFunction · 0.85
getGFXCullModeFunction · 0.85
getGFXFillModeFunction · 0.85
getGFXInputSlotClassFunction · 0.85
getGFXFormatFunction · 0.85
getFormatBytesPerBlockFunction · 0.85
getGFXPrimitiveTypeFunction · 0.85
writeRefMethod · 0.80

Tested by

no test coverage detected