CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/GPU/D3D11/StateMappingD3D11.h
Views: 1401
#pragma once12#include <cstdint>3#include <d3d11.h>45#include "Common/GPU/thin3d.h"67// TODO: Do this more progressively. No need to compute the entire state if the entire state hasn't changed.89struct D3D11BlendKey {10union {11uint64_t value;12struct {13// Blend14unsigned int blendEnable : 1;15unsigned int srcColor : 5; // D3D11_BLEND16unsigned int destColor : 5; // D3D11_BLEND17unsigned int srcAlpha : 5; // D3D11_BLEND18unsigned int destAlpha : 5; // D3D11_BLEND19unsigned int blendOpColor : 3; // D3D11_BLEND_OP20unsigned int blendOpAlpha : 3; // D3D11_BLEND_OP21unsigned int logicOpEnable : 1;22unsigned int logicOp : 4; // D3D11_LOGIC_OP23unsigned int colorWriteMask : 4;24};25};26};2728struct D3D11DepthStencilKey {29union {30uint64_t value;31struct {32// Depth/Stencil33unsigned int depthTestEnable : 1;34unsigned int depthWriteEnable : 1;35unsigned int depthCompareOp : 4; // D3D11_COMPARISON (-1 and we could fit it in 3 bits)36unsigned int stencilTestEnable : 1;37unsigned int stencilCompareFunc : 4; // D3D11_COMPARISON38unsigned int stencilPassOp : 4; // D3D11_STENCIL_OP39unsigned int stencilFailOp : 4; // D3D11_STENCIL_OP40unsigned int stencilDepthFailOp : 4; // D3D11_STENCIL_OP41unsigned int stencilWriteMask : 8; // Unfortunately these are baked into the state on D3D1142unsigned int stencilCompareMask : 8;43};44};45};4647struct D3D11RasterKey {48union {49uint32_t value;50struct {51unsigned int cullMode : 2; // D3D11_CULL_MODE52unsigned int depthClipEnable : 1;53};54};55};5657// In D3D11 we cache blend state objects etc, and we simply emit keys, which are then also used to create these objects.58struct D3D11StateKeys {59D3D11BlendKey blend;60D3D11DepthStencilKey depthStencil;61D3D11RasterKey raster;62};6364struct D3D11DynamicState {65int topology;66bool useBlendColor;67uint32_t blendColor;68bool useStencil;69uint8_t stencilRef;70Draw::Viewport viewport;71D3D11_RECT scissor;72};737475