Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DXBC pixel shader debugging with non-zero indexed semantic #3219

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

anthark
Copy link
Contributor

@anthark anthark commented Jan 17, 2024

Description

While using DirectX 12, DXBC pixel shader debugging doesn't work, when semantic with non-zero index is used between VS and PS stages and is a single semantic with this name. I've added semantic index to generated debug shader input to fix interstage communication between original VS and generated PS, when semantic index is not zero. I kept previous logic as well to not to change behavior when more than one semantics with the same name are used and one of them is not indexed, like COLOR (turns to COLOR0) and COLOR1.

Also very simple application, that reproduces issue is added: it is from official DirectX 12 samples from Microsoft, with COLOR semantic in PS input changed to COLOR1
HelloTriangle.zip

Copy link
Owner

@baldurk baldurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general note, from the CONTRIBUTING documentation please ensure all commits are properly formatted and do not include any formatting-only commits.

if(sig.semanticIndex != 0)
{
name += ToStr(sig.semanticIndex);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix does not seem correct. As in the comments on the field semanticIdxName it already includes the index when necessary as compared to semanticName, so this will duplicate it turning TEXCOORD1 into TEXCOORD11.

Perhaps the logic for that needs to be re-examined? If you're not sure you can open this as a bug report and not a pull request and I can investigate it.

Copy link
Contributor Author

@anthark anthark Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix does not seem correct. As in the comments on the field semanticIdxName it already includes the index when necessary as compared to semanticName, so this will duplicate it turning TEXCOORD1 into TEXCOORD11.

Perhaps the logic for that needs to be re-examined? If you're not sure you can open this as a bug report and not a pull request and I can investigate it.

Oh, thanks - I see where I'm wrong =)
I believe root reason for the issue goes from this code:

for(uint32_t i = 0; i < sign->numElems; i++)
{
  SigParameter &a = (*sig)[i];

  for(uint32_t j = 0; j < sign->numElems; j++)
  {
    SigParameter &b = (*sig)[j];
    if(i != j && a.semanticName == b.semanticName)
    {
      a.needSemanticIndex = true;
      break;
    }
  }

  rdcstr semanticIdxName = a.semanticName;
  if(a.needSemanticIndex)
    semanticIdxName += ToStr(a.semanticIndex);

  a.semanticIdxName = semanticIdxName;
  }
}

Which literally means, that we use semantic index as a part of semanticIdxName field only if semantic with given name is used more than once. However if we only use single semantic with given name, but non-zero index, this doesn't work =(

Os, is it OK, if I change it here to add index to the field, when semantic index is not 0?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to make more sense, it sounds quite unusual to only use a higher numbered semantic but I can see how that would break here.

If you want to update the PR that is fine, please ensure that as noted above you follow the CONTRIBUTING guidelines and remove the old commits and just have a new commit with the correct fix.

@anthark anthark force-pushed the v1.x branch 2 times, most recently from 686e3a0 to 4298b7c Compare January 23, 2024 09:06
@baldurk baldurk merged commit a55e82a into baldurk:v1.x Jan 23, 2024
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants