Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xna HLSL顶点声明语义问题_Xna_Directx_Hlsl_Monogame - Fatal编程技术网

Xna HLSL顶点声明语义问题

Xna HLSL顶点声明语义问题,xna,directx,hlsl,monogame,Xna,Directx,Hlsl,Monogame,当我在POSITION semantic中将字节4设置为顶点声明,并在着色器中使用unit4作为相应的数据类型(因为没有字节4)时会发生什么 uint4试验:位置0 如果有浮子,这里会发生什么 浮动4色调:位置0 uint4是正确的 无论顶点缓冲区数据是8位、16位还是32位整数,数据都将转换为32位整数。浮点也是如此,着色器处理32位浮点(除非使用双精度类型),并且任何输入数据都将从其基础格式转换 但是,在获取顶点缓冲区时,不能从整数和浮点转换。获得数据后,可以在浮点和整数之间自由转换,但输入

当我在POSITION semantic中将字节4设置为顶点声明,并在着色器中使用unit4作为相应的数据类型(因为没有字节4)时会发生什么

uint4试验:位置0

如果有浮子,这里会发生什么

浮动4色调:位置0

uint4是正确的

无论顶点缓冲区数据是8位、16位还是32位整数,数据都将转换为32位整数。浮点也是如此,着色器处理32位浮点(除非使用双精度类型),并且任何输入数据都将从其基础格式转换

但是,在获取顶点缓冲区时,不能从整数和浮点转换。获得数据后,可以在浮点和整数之间自由转换,但输入属性类型(uint或float)必须与输入布局中指定的DXGI_格式匹配。如果您尝试将输入声明为float4,而实际上它是uint4,则会收到类似于以下警告:

D3D11 WARNING: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'POSITION'/0 and component(s) of the type 'float32'.  However, the matching entry in the Input Layout declaration, element[0], specifies mismatched format: 'R8G8B8A8_UINT'.  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]