Skip to content

Commit

Permalink
[d3d8] Validate PS/VS version on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall authored and K0bin committed Nov 23, 2024
1 parent 423c86b commit 34165f3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,17 @@ namespace dxvk {
if (unlikely(pDeclaration == nullptr || pHandle == nullptr))
return D3DERR_INVALIDCALL;

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

if (unlikely(majorVersion != 1 || minorVersion > 1)) {
Logger::err(str::format("D3D8Device::CreateVertexShader: Unsupported VS version ", majorVersion, ".", minorVersion));
return D3DERR_INVALIDCALL;
}
}

D3D8VertexShaderInfo& info = m_vertexShaders.emplace_back();

// Store D3D8 bytecodes in the shader info
Expand Down Expand Up @@ -1926,6 +1937,14 @@ namespace dxvk {
if (unlikely(pFunction == nullptr || pHandle == nullptr))
return D3DERR_INVALIDCALL;

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

if (unlikely(majorVersion != 1 || minorVersion > 4)) {
Logger::err(str::format("D3D8Device::CreatePixelShader: Unsupported PS version ", majorVersion, ".", minorVersion));
return D3DERR_INVALIDCALL;
}

d3d9::IDirect3DPixelShader9* pPixelShader;

HRESULT res = GetD3D9()->CreatePixelShader(pFunction, &pPixelShader);
Expand Down

0 comments on commit 34165f3

Please sign in to comment.