Skip to content

Commit

Permalink
[d3d8/9] Use shader version macros where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Jan 28, 2025
1 parent de4b1eb commit f1ab09e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,8 @@ namespace dxvk {

// Validate VS version for non-FF shaders
if (pFunction != nullptr) {
const uint32_t majorVersion = (pFunction[0] >> 8) & 0xff;
const uint32_t minorVersion = pFunction[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);

if (unlikely(majorVersion != 1 || minorVersion > 1)) {
Logger::err(str::format("D3D8Device::CreateVertexShader: Unsupported VS version ", majorVersion, ".", minorVersion));
Expand Down Expand Up @@ -2029,8 +2029,8 @@ namespace dxvk {
if (unlikely(pFunction == nullptr || pHandle == nullptr))
return D3DERR_INVALIDCALL;

const uint32_t majorVersion = (pFunction[0] >> 8) & 0xff;
const uint32_t minorVersion = pFunction[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);

if (unlikely(m_isFixedFunctionOnly || majorVersion != 1 || minorVersion > 4)) {
Logger::err(str::format("D3D8Device::CreatePixelShader: Unsupported PS version ", majorVersion, ".", minorVersion));
Expand Down
8 changes: 4 additions & 4 deletions src/d3d8/d3d8_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ extern "C" {
if (unlikely(pPixelShader == nullptr)) {
errorMessage = "D3D8: ValidatePixelShader: Null pPixelShader";
} else {
const uint32_t majorVersion = (pPixelShader[0] >> 8) & 0xff;
const uint32_t minorVersion = pPixelShader[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pPixelShader[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pPixelShader[0]);

if (unlikely(majorVersion != 1 || minorVersion > 4)) {
errorMessage = dxvk::str::format("D3D8: ValidatePixelShader: Unsupported PS version ",
Expand Down Expand Up @@ -69,8 +69,8 @@ extern "C" {
if (unlikely(pVertexShader == nullptr)) {
errorMessage = "D3D8: ValidateVertexShader: Null pVertexShader";
} else {
const uint32_t majorVersion = (pVertexShader[0] >> 8) & 0xff;
const uint32_t minorVersion = pVertexShader[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pVertexShader[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pVertexShader[0]);

if (unlikely(majorVersion != 1 || minorVersion > 1)) {
errorMessage = dxvk::str::format("D3D8: ValidateVertexShader: Unsupported VS version ",
Expand Down
8 changes: 4 additions & 4 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3314,8 +3314,8 @@ namespace dxvk {
if (unlikely(ppShader == nullptr))
return D3DERR_INVALIDCALL;

const uint32_t majorVersion = (pFunction[0] >> 8) & 0xff;
const uint32_t minorVersion = pFunction[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);

// Late fixed-function capable hardware exposed support for VS 1.1
const uint32_t shaderModelVS = m_d3d9Options.shaderModel == 0 ? 1 : m_d3d9Options.shaderModel;
Expand Down Expand Up @@ -3692,8 +3692,8 @@ namespace dxvk {
if (unlikely(ppShader == nullptr))
return D3DERR_INVALIDCALL;

const uint32_t majorVersion = (pFunction[0] >> 8) & 0xff;
const uint32_t minorVersion = pFunction[0] & 0xff;
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);

if (unlikely(majorVersion > m_d3d9Options.shaderModel
|| (majorVersion == 1 && minorVersion > 4)
Expand Down
4 changes: 2 additions & 2 deletions src/d3d9/d3d9_shader_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ namespace dxvk {
"IDirect3DShaderValidator9::Instruction: Bad version token. It indicates neither a pixel shader nor a vertex shader.");
}

m_majorVersion = (headerToken >> 8) & 0xff;
m_minorVersion = headerToken & 0xff;
m_majorVersion = D3DSHADER_VERSION_MAJOR(headerToken);
m_minorVersion = D3DSHADER_VERSION_MINOR(headerToken);
m_ctx = std::make_unique<DxsoDecodeContext>(DxsoProgramInfo{ programType, m_minorVersion, m_majorVersion });
m_state = D3D9ShaderValidatorState::ValidatingInstructions;

Expand Down

0 comments on commit f1ab09e

Please sign in to comment.