Skip to content

Commit

Permalink
[d3d9] fix opCompositeExtract out of bound
Browse files Browse the repository at this point in the history
Closes: doitsujin#3293

Signed-by: Oleksii Bozhenko <oleksii.bozhenko@globallogic.com>
  • Loading branch information
AlexBozhenk authored and Etaash-mathamsetty committed Jul 16, 2023
1 parent b06a072 commit d5e05f4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/d3d9/d3d9_fixed_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,19 +1102,30 @@ namespace dxvk {
m_module.opStore(m_vs.out.NORMAL, outNrm);

for (uint32_t i = 0; i < caps::TextureStageCount; i++) {
uint32_t inputIndex = (m_vsKey.Data.Contents.TexcoordIndices >> (i * 3)) & 0b111;
uint32_t inputFlags = (m_vsKey.Data.Contents.TexcoordFlags >> (i * 3)) & 0b111;
uint32_t inputIndex = (m_vsKey.Data.Contents.TexcoordIndices >> (i * 3)) & 0b111;
uint32_t inputFlags = (m_vsKey.Data.Contents.TexcoordFlags >> (i * 3)) & 0b111;
uint32_t texcoordCount = (m_vsKey.Data.Contents.TexcoordDeclMask >> (i * 3)) & 0b111;

uint32_t transformed;

const uint32_t wIndex = 3;

uint32_t flags = (m_vsKey.Data.Contents.TransformFlags >> (i * 3)) & 0b111;
uint32_t count = flags;
uint32_t count;
switch (inputFlags) {
default:
case (DXVK_TSS_TCI_PASSTHRU >> TCIOffset):
transformed = m_vs.in.TEXCOORD[inputIndex & 0xFF];
// flags is actually the number of elements that get passed
// to the rasterizer.
count = flags;
if (texcoordCount) {
// Clamp by the number of elements in the texcoord input.
if (!count || count > texcoordCount)
count = texcoordCount;
}
else
flags = D3DTTFF_DISABLE;
break;

case (DXVK_TSS_TCI_CAMERASPACENORMAL >> TCIOffset):
Expand Down Expand Up @@ -1798,10 +1809,9 @@ namespace dxvk {
texcoord, texcoord, texcoordCnt, indices.data());

uint32_t projIdx = m_fsKey.Stages[i].Contents.ProjectedCount;
if (projIdx == 0)
if (projIdx == 0 || projIdx > texcoordCnt)
projIdx = texcoordCnt;
else
projIdx--;
--projIdx;

uint32_t projValue = 0;

Expand Down

0 comments on commit d5e05f4

Please sign in to comment.