2019-12-16 04:28:01 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "d3d9_device_child.h"
|
|
|
|
#include "d3d9_device.h"
|
|
|
|
#include "d3d9_state.h"
|
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
#include "../util/util_bit.h"
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
namespace dxvk {
|
|
|
|
|
2019-12-16 22:52:43 +01:00
|
|
|
enum class D3D9CapturedStateFlag : uint32_t {
|
|
|
|
VertexDecl,
|
|
|
|
Indices,
|
|
|
|
RenderStates,
|
|
|
|
SamplerStates,
|
|
|
|
VertexBuffers,
|
|
|
|
Textures,
|
|
|
|
VertexShader,
|
|
|
|
PixelShader,
|
|
|
|
Viewport,
|
|
|
|
ScissorRect,
|
|
|
|
ClipPlanes,
|
|
|
|
VsConstants,
|
|
|
|
PsConstants,
|
|
|
|
StreamFreq,
|
|
|
|
Transforms,
|
|
|
|
TextureStages,
|
2022-11-21 00:37:39 +01:00
|
|
|
Material,
|
|
|
|
Lights
|
2019-12-16 22:52:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
using D3D9CapturedStateFlags = Flags<D3D9CapturedStateFlag>;
|
|
|
|
|
|
|
|
struct D3D9StateCaptures {
|
|
|
|
D3D9CapturedStateFlags flags;
|
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<RenderStateCount> renderStates;
|
2019-12-16 22:52:43 +01:00
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<SamplerCount> samplers;
|
2019-12-16 22:52:43 +01:00
|
|
|
std::array<
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<SamplerStateCount>,
|
2019-12-16 22:52:43 +01:00
|
|
|
SamplerCount> samplerStates;
|
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<caps::MaxStreams> vertexBuffers;
|
|
|
|
bit::bitset<SamplerCount> textures;
|
|
|
|
bit::bitset<caps::MaxClipPlanes> clipPlanes;
|
|
|
|
bit::bitset<caps::MaxStreams> streamFreq;
|
|
|
|
bit::bitset<caps::MaxTransforms> transforms;
|
|
|
|
bit::bitset<caps::TextureStageCount> textureStages;
|
2019-12-16 22:52:43 +01:00
|
|
|
std::array<
|
2020-01-23 00:51:57 +01:00
|
|
|
bit::bitset<TextureStageStateCount>,
|
2019-12-16 22:52:43 +01:00
|
|
|
caps::TextureStageCount> textureStageStates;
|
|
|
|
|
|
|
|
struct {
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<caps::MaxFloatConstantsSoftware> fConsts;
|
|
|
|
bit::bitset<caps::MaxOtherConstantsSoftware> iConsts;
|
|
|
|
bit::bitset<caps::MaxOtherConstantsSoftware> bConsts;
|
2019-12-16 22:52:43 +01:00
|
|
|
} vsConsts;
|
|
|
|
|
|
|
|
struct {
|
2019-12-17 02:05:32 +01:00
|
|
|
bit::bitset<caps::MaxFloatConstantsPS> fConsts;
|
|
|
|
bit::bitset<caps::MaxOtherConstants> iConsts;
|
|
|
|
bit::bitset<caps::MaxOtherConstants> bConsts;
|
2019-12-16 22:52:43 +01:00
|
|
|
} psConsts;
|
2022-11-21 00:37:39 +01:00
|
|
|
|
|
|
|
bit::bitvector lightEnabledChanges;
|
2019-12-16 22:52:43 +01:00
|
|
|
};
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
enum class D3D9StateBlockType :uint32_t {
|
|
|
|
None,
|
|
|
|
VertexState,
|
|
|
|
PixelState,
|
|
|
|
All
|
|
|
|
};
|
|
|
|
|
|
|
|
inline D3D9StateBlockType ConvertStateBlockType(D3DSTATEBLOCKTYPE type) {
|
|
|
|
switch (type) {
|
|
|
|
case D3DSBT_PIXELSTATE: return D3D9StateBlockType::PixelState;
|
|
|
|
case D3DSBT_VERTEXSTATE: return D3D9StateBlockType::VertexState;
|
|
|
|
default:
|
|
|
|
case D3DSBT_ALL: return D3D9StateBlockType::All;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using D3D9StateBlockBase = D3D9DeviceChild<IDirect3DStateBlock9>;
|
|
|
|
class D3D9StateBlock : public D3D9StateBlockBase {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
D3D9StateBlock(D3D9DeviceEx* pDevice, D3D9StateBlockType Type);
|
|
|
|
|
2023-06-10 01:18:05 +02:00
|
|
|
~D3D9StateBlock();
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject) final;
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Capture() final;
|
|
|
|
HRESULT STDMETHODCALLTYPE Apply() final;
|
|
|
|
|
|
|
|
HRESULT SetVertexDeclaration(D3D9VertexDecl* pDecl);
|
|
|
|
|
|
|
|
HRESULT SetIndices(D3D9IndexBuffer* pIndexData);
|
|
|
|
|
|
|
|
HRESULT SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
|
|
|
|
|
|
|
|
HRESULT SetStateSamplerState(
|
|
|
|
DWORD StateSampler,
|
|
|
|
D3DSAMPLERSTATETYPE Type,
|
|
|
|
DWORD Value);
|
|
|
|
|
|
|
|
HRESULT SetStreamSource(
|
|
|
|
UINT StreamNumber,
|
|
|
|
D3D9VertexBuffer* pStreamData,
|
|
|
|
UINT OffsetInBytes,
|
|
|
|
UINT Stride);
|
|
|
|
|
2024-03-13 01:25:16 +01:00
|
|
|
HRESULT SetStreamSourceWithoutOffset(
|
|
|
|
UINT StreamNumber,
|
|
|
|
D3D9VertexBuffer* pStreamData,
|
|
|
|
UINT Stride);
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
HRESULT SetStreamSourceFreq(UINT StreamNumber, UINT Setting);
|
|
|
|
|
|
|
|
HRESULT SetStateTexture(DWORD StateSampler, IDirect3DBaseTexture9* pTexture);
|
|
|
|
|
|
|
|
HRESULT SetVertexShader(D3D9VertexShader* pShader);
|
|
|
|
|
|
|
|
HRESULT SetPixelShader(D3D9PixelShader* pShader);
|
|
|
|
|
|
|
|
HRESULT SetMaterial(const D3DMATERIAL9* pMaterial);
|
|
|
|
|
2022-11-21 00:37:39 +01:00
|
|
|
HRESULT SetLight(DWORD Index, const D3DLIGHT9* pLight);
|
|
|
|
|
|
|
|
HRESULT LightEnable(DWORD Index, BOOL Enable);
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
HRESULT SetStateTransform(uint32_t idx, const D3DMATRIX* pMatrix);
|
|
|
|
|
2020-01-23 00:51:57 +01:00
|
|
|
HRESULT SetStateTextureStageState(
|
|
|
|
DWORD Stage,
|
|
|
|
D3D9TextureStageStateTypes Type,
|
|
|
|
DWORD Value);
|
2019-12-16 04:28:01 +01:00
|
|
|
|
|
|
|
HRESULT MultiplyStateTransform(uint32_t idx, const D3DMATRIX* pMatrix);
|
|
|
|
|
|
|
|
HRESULT SetViewport(const D3DVIEWPORT9* pViewport);
|
|
|
|
|
|
|
|
HRESULT SetScissorRect(const RECT* pRect);
|
|
|
|
|
|
|
|
HRESULT SetClipPlane(DWORD Index, const float* pPlane);
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT SetVertexShaderConstantF(
|
|
|
|
UINT StartRegister,
|
|
|
|
const float* pConstantData,
|
|
|
|
UINT Vector4fCount);
|
|
|
|
|
|
|
|
HRESULT SetVertexShaderConstantI(
|
|
|
|
UINT StartRegister,
|
|
|
|
const int* pConstantData,
|
|
|
|
UINT Vector4iCount);
|
|
|
|
|
|
|
|
HRESULT SetVertexShaderConstantB(
|
|
|
|
UINT StartRegister,
|
|
|
|
const BOOL* pConstantData,
|
|
|
|
UINT BoolCount);
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT SetPixelShaderConstantF(
|
|
|
|
UINT StartRegister,
|
|
|
|
const float* pConstantData,
|
|
|
|
UINT Vector4fCount);
|
|
|
|
|
|
|
|
HRESULT SetPixelShaderConstantI(
|
|
|
|
UINT StartRegister,
|
|
|
|
const int* pConstantData,
|
|
|
|
UINT Vector4iCount);
|
|
|
|
|
|
|
|
HRESULT SetPixelShaderConstantB(
|
|
|
|
UINT StartRegister,
|
|
|
|
const BOOL* pConstantData,
|
|
|
|
UINT BoolCount);
|
|
|
|
|
|
|
|
enum class D3D9StateFunction {
|
|
|
|
Apply,
|
|
|
|
Capture
|
|
|
|
};
|
|
|
|
|
2024-03-13 01:25:16 +01:00
|
|
|
template <typename Dst, typename Src, bool IgnoreStreamOffset>
|
2019-12-16 04:28:01 +01:00
|
|
|
void ApplyOrCapture(Dst* dst, const Src* src) {
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::StreamFreq)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t idx : bit::BitMask(m_captures.streamFreq.dword(0)))
|
2020-01-23 00:20:13 +01:00
|
|
|
dst->SetStreamSourceFreq(idx, src->streamFreq[idx]);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Indices))
|
|
|
|
dst->SetIndices(src->indices.ptr());
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::RenderStates)) {
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.renderStates.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t rs : bit::BitMask(m_captures.renderStates.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + rs;
|
2019-12-17 02:05:32 +01:00
|
|
|
|
|
|
|
dst->SetRenderState(D3DRENDERSTATETYPE(idx), src->renderStates[idx]);
|
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::SamplerStates)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t samplerIdx : bit::BitMask(m_captures.samplers.dword(0))) {
|
|
|
|
for (uint32_t stateIdx : bit::BitMask(m_captures.samplerStates[samplerIdx].dword(0)))
|
2020-01-23 00:20:13 +01:00
|
|
|
dst->SetStateSamplerState(samplerIdx, D3DSAMPLERSTATETYPE(stateIdx), src->samplerStates[samplerIdx][stateIdx]);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::VertexBuffers)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t idx : bit::BitMask(m_captures.vertexBuffers.dword(0))) {
|
2020-01-23 00:20:13 +01:00
|
|
|
const auto& vbo = src->vertexBuffers[idx];
|
2024-03-13 01:25:16 +01:00
|
|
|
if constexpr (!IgnoreStreamOffset) {
|
|
|
|
dst->SetStreamSource(
|
|
|
|
idx,
|
|
|
|
vbo.vertexBuffer.ptr(),
|
|
|
|
vbo.offset,
|
|
|
|
vbo.stride);
|
|
|
|
} else {
|
|
|
|
// For whatever reason, D3D9 doesn't capture the stream offset
|
|
|
|
dst->SetStreamSourceWithoutOffset(
|
|
|
|
idx,
|
|
|
|
vbo.vertexBuffer.ptr(),
|
|
|
|
vbo.stride);
|
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Material))
|
|
|
|
dst->SetMaterial(&src->material);
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Textures)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t idx : bit::BitMask(m_captures.textures.dword(0)))
|
2020-01-23 00:20:13 +01:00
|
|
|
dst->SetStateTexture(idx, src->textures[idx]);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::VertexShader))
|
|
|
|
dst->SetVertexShader(src->vertexShader.ptr());
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::PixelShader))
|
|
|
|
dst->SetPixelShader(src->pixelShader.ptr());
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Transforms)) {
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.transforms.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t trans : bit::BitMask(m_captures.transforms.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + trans;
|
2019-12-17 02:05:32 +01:00
|
|
|
|
|
|
|
dst->SetStateTransform(idx, reinterpret_cast<const D3DMATRIX*>(&src->transforms[idx]));
|
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::TextureStages)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t stageIdx : bit::BitMask(m_captures.textureStages.dword(0))) {
|
|
|
|
for (uint32_t stateIdx : bit::BitMask(m_captures.textureStageStates[stageIdx].dword(0)))
|
2020-01-23 00:51:57 +01:00
|
|
|
dst->SetStateTextureStageState(stageIdx, D3D9TextureStageStateTypes(stateIdx), src->textureStages[stageIdx][stateIdx]);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Viewport))
|
|
|
|
dst->SetViewport(&src->viewport);
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::ScissorRect))
|
|
|
|
dst->SetScissorRect(&src->scissorRect);
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::ClipPlanes)) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t idx : bit::BitMask(m_captures.clipPlanes.dword(0)))
|
2020-01-23 00:20:13 +01:00
|
|
|
dst->SetClipPlane(idx, src->clipPlanes[idx].coeff);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::VsConstants)) {
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.vsConsts.fConsts.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t consts : bit::BitMask(m_captures.vsConsts.fConsts.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + consts;
|
2019-12-16 04:28:01 +01:00
|
|
|
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetVertexShaderConstantF(idx, (float*)&src->vsConsts->fConsts[idx], 1);
|
2019-12-17 02:05:32 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.vsConsts.iConsts.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t consts : bit::BitMask(m_captures.vsConsts.iConsts.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + consts;
|
2019-12-16 04:28:01 +01:00
|
|
|
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetVertexShaderConstantI(idx, (int*)&src->vsConsts->iConsts[idx], 1);
|
2019-12-17 02:05:32 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
2019-12-17 02:05:32 +01:00
|
|
|
|
2019-12-17 04:01:17 +01:00
|
|
|
if (m_captures.vsConsts.bConsts.any()) {
|
|
|
|
for (uint32_t i = 0; i < m_captures.vsConsts.bConsts.dwordCount(); i++)
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetVertexBoolBitfield(i, m_captures.vsConsts.bConsts.dword(i), src->vsConsts->bConsts[i]);
|
2019-12-17 04:01:17 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::PsConstants)) {
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.psConsts.fConsts.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t consts : bit::BitMask(m_captures.psConsts.fConsts.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + consts;
|
2019-12-16 04:28:01 +01:00
|
|
|
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetPixelShaderConstantF(idx, (float*)&src->psConsts->fConsts[idx], 1);
|
2019-12-17 02:05:32 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 02:05:32 +01:00
|
|
|
for (uint32_t i = 0; i < m_captures.psConsts.iConsts.dwordCount(); i++) {
|
2021-08-13 18:48:09 +02:00
|
|
|
for (uint32_t consts : bit::BitMask(m_captures.psConsts.iConsts.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + consts;
|
2019-12-17 02:05:32 +01:00
|
|
|
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetPixelShaderConstantI(idx, (int*)&src->psConsts->iConsts[idx], 1);
|
2019-12-17 02:05:32 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 04:01:17 +01:00
|
|
|
if (m_captures.psConsts.bConsts.any()) {
|
|
|
|
for (uint32_t i = 0; i < m_captures.psConsts.bConsts.dwordCount(); i++)
|
2023-02-11 22:39:05 +01:00
|
|
|
dst->SetPixelBoolBitfield(i, m_captures.psConsts.bConsts.dword(i), src->psConsts->bConsts[i]);
|
2019-12-17 04:01:17 +01:00
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
2022-11-21 00:37:39 +01:00
|
|
|
|
|
|
|
if (m_captures.flags.test(D3D9CapturedStateFlag::Lights)) {
|
2023-02-18 15:42:42 +01:00
|
|
|
for (uint32_t i = 0; i < src->lights.size(); i++) {
|
|
|
|
if (!src->lights[i].has_value())
|
2022-11-21 00:37:39 +01:00
|
|
|
continue;
|
|
|
|
|
2023-02-18 15:42:42 +01:00
|
|
|
dst->SetLight(i, &src->lights[i].value());
|
2022-11-21 00:37:39 +01:00
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < m_captures.lightEnabledChanges.dwordCount(); i++) {
|
|
|
|
for (uint32_t consts : bit::BitMask(m_captures.lightEnabledChanges.dword(i))) {
|
|
|
|
uint32_t idx = i * 32 + consts;
|
|
|
|
|
2023-02-18 15:42:42 +01:00
|
|
|
dst->LightEnable(idx, src->IsLightEnabled(idx));
|
2022-11-21 00:37:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
2024-03-13 01:25:16 +01:00
|
|
|
template <D3D9StateFunction Func, bool IgnoreStreamOffset>
|
2019-12-16 04:28:01 +01:00
|
|
|
void ApplyOrCapture() {
|
|
|
|
if constexpr (Func == D3D9StateFunction::Apply)
|
2024-03-13 01:25:16 +01:00
|
|
|
ApplyOrCapture<D3D9DeviceEx, D3D9CapturableState, IgnoreStreamOffset>(m_parent, &m_state);
|
2019-12-16 04:28:01 +01:00
|
|
|
else if constexpr (Func == D3D9StateFunction::Capture)
|
2024-03-13 01:25:16 +01:00
|
|
|
ApplyOrCapture<D3D9StateBlock, D3D9DeviceState, IgnoreStreamOffset>(this, m_deviceState);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <
|
|
|
|
DxsoProgramType ProgramType,
|
|
|
|
D3D9ConstantType ConstantType,
|
|
|
|
typename T>
|
|
|
|
HRESULT SetShaderConstants(
|
|
|
|
UINT StartRegister,
|
|
|
|
const T* pConstantData,
|
|
|
|
UINT Count) {
|
|
|
|
auto SetHelper = [&](auto& setCaptures) {
|
|
|
|
if constexpr (ProgramType == DxsoProgramTypes::VertexShader)
|
|
|
|
m_captures.flags.set(D3D9CapturedStateFlag::VsConstants);
|
|
|
|
else
|
|
|
|
m_captures.flags.set(D3D9CapturedStateFlag::PsConstants);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < Count; i++) {
|
|
|
|
uint32_t reg = StartRegister + i;
|
|
|
|
if constexpr (ConstantType == D3D9ConstantType::Float)
|
2019-12-17 02:05:32 +01:00
|
|
|
setCaptures.fConsts.set(reg, true);
|
2019-12-16 04:28:01 +01:00
|
|
|
else if constexpr (ConstantType == D3D9ConstantType::Int)
|
2019-12-17 02:05:32 +01:00
|
|
|
setCaptures.iConsts.set(reg, true);
|
2019-12-16 04:28:01 +01:00
|
|
|
else if constexpr (ConstantType == D3D9ConstantType::Bool)
|
2019-12-17 02:05:32 +01:00
|
|
|
setCaptures.bConsts.set(reg, true);
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateStateConstants<
|
|
|
|
ProgramType,
|
|
|
|
ConstantType,
|
|
|
|
T>(
|
|
|
|
&m_state,
|
|
|
|
StartRegister,
|
|
|
|
pConstantData,
|
|
|
|
Count,
|
|
|
|
false);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
return ProgramType == DxsoProgramTypes::VertexShader
|
|
|
|
? SetHelper(m_captures.vsConsts)
|
|
|
|
: SetHelper(m_captures.psConsts);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT SetVertexBoolBitfield(uint32_t idx, uint32_t mask, uint32_t bits);
|
|
|
|
HRESULT SetPixelBoolBitfield (uint32_t idx, uint32_t mask, uint32_t bits);
|
|
|
|
|
|
|
|
inline bool IsApplying() {
|
|
|
|
return m_applying;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void CapturePixelRenderStates();
|
|
|
|
void CapturePixelSamplerStates();
|
|
|
|
void CapturePixelShaderStates();
|
|
|
|
|
|
|
|
void CaptureVertexRenderStates();
|
|
|
|
void CaptureVertexSamplerStates();
|
|
|
|
void CaptureVertexShaderStates();
|
|
|
|
|
|
|
|
void CaptureType(D3D9StateBlockType State);
|
|
|
|
|
|
|
|
D3D9CapturableState m_state;
|
|
|
|
D3D9StateCaptures m_captures;
|
|
|
|
|
2023-02-11 22:39:05 +01:00
|
|
|
D3D9DeviceState* m_deviceState;
|
2019-12-16 04:28:01 +01:00
|
|
|
|
|
|
|
bool m_applying = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|