D3D: State cache now uses BitField to define packed render states
This commit is contained in:
parent
2e4667caaa
commit
e7f8032d7d
|
@ -614,7 +614,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
|||
}
|
||||
else
|
||||
{
|
||||
gx_state.blend.blend_enable = bpmem.blendmode.blendenable;
|
||||
gx_state.blend.blend_enable = (u32)bpmem.blendmode.blendenable;
|
||||
if (bpmem.blendmode.blendenable)
|
||||
{
|
||||
SetBlendOp(D3D11_BLEND_OP_ADD);
|
||||
|
@ -1213,15 +1213,15 @@ void Renderer::SetSamplerState(int stage, int texindex)
|
|||
}
|
||||
else
|
||||
{
|
||||
gx_state.sampler[stage].min_filter = tm0.min_filter;
|
||||
gx_state.sampler[stage].mag_filter = tm0.mag_filter;
|
||||
gx_state.sampler[stage].min_filter = (u32)tm0.min_filter;
|
||||
gx_state.sampler[stage].mag_filter = (u32)tm0.mag_filter;
|
||||
}
|
||||
|
||||
gx_state.sampler[stage].wrap_s = tm0.wrap_s;
|
||||
gx_state.sampler[stage].wrap_t = tm0.wrap_t;
|
||||
gx_state.sampler[stage].max_lod = tm1.max_lod;
|
||||
gx_state.sampler[stage].min_lod = tm1.min_lod;
|
||||
gx_state.sampler[stage].lod_bias = tm0.lod_bias;
|
||||
gx_state.sampler[stage].wrap_s = (u32)tm0.wrap_s;
|
||||
gx_state.sampler[stage].wrap_t = (u32)tm0.wrap_t;
|
||||
gx_state.sampler[stage].max_lod = (u32)tm1.max_lod;
|
||||
gx_state.sampler[stage].min_lod = (u32)tm1.min_lod;
|
||||
gx_state.sampler[stage].lod_bias = (s32)tm0.lod_bias;
|
||||
}
|
||||
|
||||
void Renderer::SetInterlacingMode()
|
||||
|
|
|
@ -38,7 +38,7 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)
|
|||
if (state.max_anisotropy)
|
||||
{
|
||||
sampdc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
sampdc.MaxAnisotropy = state.max_anisotropy;
|
||||
sampdc.MaxAnisotropy = (u32)state.max_anisotropy;
|
||||
}
|
||||
else if (state.min_filter & 4) // linear min filter
|
||||
{
|
||||
|
@ -114,13 +114,13 @@ ID3D11BlendState* StateCache::Get(BlendState state)
|
|||
blenddc.AlphaToCoverageEnable = FALSE;
|
||||
blenddc.IndependentBlendEnable = FALSE;
|
||||
blenddc.RenderTarget[0].BlendEnable = state.blend_enable;
|
||||
blenddc.RenderTarget[0].RenderTargetWriteMask = (D3D11_COLOR_WRITE_ENABLE)state.write_mask;
|
||||
blenddc.RenderTarget[0].SrcBlend = (D3D11_BLEND)state.src_blend;
|
||||
blenddc.RenderTarget[0].DestBlend = (D3D11_BLEND)state.dst_blend;
|
||||
blenddc.RenderTarget[0].BlendOp = (D3D11_BLEND_OP)state.blend_op;
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = (D3D11_BLEND)state.src_blend;
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = (D3D11_BLEND)state.dst_blend;
|
||||
blenddc.RenderTarget[0].BlendOpAlpha = (D3D11_BLEND_OP)state.blend_op;
|
||||
blenddc.RenderTarget[0].RenderTargetWriteMask = (u32)state.write_mask;
|
||||
blenddc.RenderTarget[0].SrcBlend = state.src_blend;
|
||||
blenddc.RenderTarget[0].DestBlend = state.dst_blend;
|
||||
blenddc.RenderTarget[0].BlendOp = state.blend_op;
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = state.src_blend;
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = state.dst_blend;
|
||||
blenddc.RenderTarget[0].BlendOpAlpha = state.blend_op;
|
||||
|
||||
if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_COLOR)
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
||||
|
@ -183,7 +183,7 @@ ID3D11RasterizerState* StateCache::Get(RasterizerState state)
|
|||
}
|
||||
|
||||
D3D11_RASTERIZER_DESC rastdc = CD3D11_RASTERIZER_DESC(state.wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID,
|
||||
(D3D11_CULL_MODE)state.cull_mode,
|
||||
state.cull_mode,
|
||||
false, 0, 0.f, 0, false, true, false, false);
|
||||
|
||||
ID3D11RasterizerState* res = nullptr;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Common/BitField.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
|
@ -15,43 +16,34 @@ namespace DX11
|
|||
|
||||
union RasterizerState
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 cull_mode : 2;
|
||||
u32 wireframe : 1;
|
||||
};
|
||||
BitField<0, 2, D3D11_CULL_MODE> cull_mode;
|
||||
BitField<2, 1, u32> wireframe;
|
||||
|
||||
u32 packed;
|
||||
};
|
||||
|
||||
union BlendState
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 blend_enable : 1;
|
||||
u32 blend_op : 3;
|
||||
u32 write_mask : 4;
|
||||
u32 src_blend : 5;
|
||||
u32 dst_blend : 5;
|
||||
u32 use_dst_alpha : 1;
|
||||
};
|
||||
BitField<0, 1, u32> blend_enable;
|
||||
BitField<1, 3, D3D11_BLEND_OP> blend_op;
|
||||
BitField<4, 4, u32> write_mask;
|
||||
BitField<8, 5, D3D11_BLEND> src_blend;
|
||||
BitField<13, 5, D3D11_BLEND> dst_blend;
|
||||
BitField<18, 1, u32> use_dst_alpha;
|
||||
|
||||
u32 packed;
|
||||
};
|
||||
|
||||
union SamplerState
|
||||
{
|
||||
struct
|
||||
{
|
||||
u64 min_filter : 3;
|
||||
u64 mag_filter : 1;
|
||||
u64 min_lod : 8;
|
||||
u64 max_lod : 8;
|
||||
s64 lod_bias : 8;
|
||||
u64 wrap_s : 2;
|
||||
u64 wrap_t : 2;
|
||||
u64 max_anisotropy : 5;
|
||||
};
|
||||
BitField<0, 3, u64> min_filter;
|
||||
BitField<3, 1, u64> mag_filter;
|
||||
BitField<4, 8, u64> min_lod;
|
||||
BitField<12, 8, u64> max_lod;
|
||||
BitField<20, 8, s64> lod_bias;
|
||||
BitField<28, 2, u64> wrap_s;
|
||||
BitField<30, 2, u64> wrap_t;
|
||||
BitField<32, 5, u64> max_anisotropy;
|
||||
|
||||
u64 packed;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue