baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.
https://renderdoc.org
MIT License
8.88k stars 1.33k forks source link

Warn about inappropriate usage of glVertexAttribFormat #2013

Closed nicebyte closed 4 years ago

nicebyte commented 4 years ago

Description

When specifying vertex attribute format for integer attributes, it is a common mistake to call glVertexAttribFormat instead of glVertexAttribIFormat.

Currently, RenderDoc simply displays the values of attributes specified in this erroneous way without any indication that something might be wrong, even though the application might be exhibiting incorrect behaviour.

It can make this type of bug hard to spot. Theoretically, it should be possible to detect this situation and warn the user about it, though I am not sure what might be the best way to surface this information to the user (stick an error message instead of the attribute value perhaps?)

Environment

baldurk commented 4 years ago

In that commit I've added information to the GL pipeline state viewer for the vertex attributes to show where integer data is being converted to float (and possibly normalised):

image

However API validation is explicitly not in scope for RenderDoc. This kind of thing is the responsibility for the API's validation, and e.g. on D3D11 you get a warning about this behaviour:

D3D11 WARNING: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'COLOR'/0 and component(s) of the type 'int32'. However, the matching entry in the Input Layout declaration, element[1], specifies mismatched format: 'R32_FLOAT'. This is not an error, since behavior is well defined: The element format determines what data conversion algorithm gets applied before it shows up in a shader register. Independently, the shader input signature defines how the shader will interpret the data that has been placed in its input registers, with no change in the bits stored. It is valid for the application to reinterpret data as a different type once it is in the vertex shader, so this warning is issued just in case reinterpretation was not intended by the author. [ STATE_CREATION WARNING #391: CREATEINPUTLAYOUT_TYPE_MISMATCH]