mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-01 15:39:47 +08:00
[ShaderCompiler/Vulkan] Match vertex input numeric types (#351)
Declare UINT and SINT vertex attributes with integer SPIR-V component types so shader interfaces match the Vulkan pipeline formats. Keep normalized, scaled, and floating-point formats on float inputs. Signed-off-by: missatjuhvdk1 <177474143+missatjuhvdk1@users.noreply.github.com> Co-authored-by: missatjuhvdk1 <177474143+missatjuhvdk1@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
0b1dea43e8
commit
743fe5cc26
@@ -299,6 +299,13 @@ public static partial class Gen5SpirvTranslator
|
||||
Uint,
|
||||
}
|
||||
|
||||
private enum VertexInputComponentKind
|
||||
{
|
||||
Float,
|
||||
Sint,
|
||||
Uint,
|
||||
}
|
||||
|
||||
private readonly record struct SpirvImageResource(
|
||||
uint Variable,
|
||||
uint ImageType,
|
||||
@@ -311,7 +318,9 @@ public static partial class Gen5SpirvTranslator
|
||||
private readonly record struct SpirvVertexInput(
|
||||
uint Variable,
|
||||
uint Type,
|
||||
uint ComponentCount);
|
||||
uint ComponentType,
|
||||
uint ComponentCount,
|
||||
VertexInputComponentKind ComponentKind);
|
||||
|
||||
private readonly record struct SpirvPixelOutput(
|
||||
uint Variable,
|
||||
@@ -1289,12 +1298,23 @@ public static partial class Gen5SpirvTranslator
|
||||
{
|
||||
foreach (var input in _evaluation.VertexInputs ?? [])
|
||||
{
|
||||
var componentKind = input.NumberFormat switch
|
||||
{
|
||||
4 => VertexInputComponentKind.Uint,
|
||||
5 => VertexInputComponentKind.Sint,
|
||||
_ => VertexInputComponentKind.Float,
|
||||
};
|
||||
var componentType = componentKind switch
|
||||
{
|
||||
VertexInputComponentKind.Uint => _uintType,
|
||||
VertexInputComponentKind.Sint => _intType,
|
||||
_ => _floatType,
|
||||
};
|
||||
var type = input.ComponentCount switch
|
||||
{
|
||||
1u => _floatType,
|
||||
2u => _vec2Type,
|
||||
3u => _vec3Type,
|
||||
4u => _vec4Type,
|
||||
1u => componentType,
|
||||
>= 2u and <= 4u =>
|
||||
_module.TypeVector(componentType, input.ComponentCount),
|
||||
_ => 0u,
|
||||
};
|
||||
if (type == 0)
|
||||
@@ -1316,7 +1336,9 @@ public static partial class Gen5SpirvTranslator
|
||||
new SpirvVertexInput(
|
||||
variable,
|
||||
type,
|
||||
input.ComponentCount));
|
||||
componentType,
|
||||
input.ComponentCount,
|
||||
componentKind));
|
||||
_interfaces.Add(variable);
|
||||
}
|
||||
}
|
||||
@@ -3198,10 +3220,13 @@ public static partial class Gen5SpirvTranslator
|
||||
? loaded
|
||||
: _module.AddInstruction(
|
||||
SpirvOp.CompositeExtract,
|
||||
_floatType,
|
||||
input.ComponentType,
|
||||
loaded,
|
||||
component);
|
||||
StoreV(control.VectorData + component, Bitcast(_uintType, value));
|
||||
var raw = input.ComponentKind == VertexInputComponentKind.Uint
|
||||
? value
|
||||
: Bitcast(_uintType, value);
|
||||
StoreV(control.VectorData + component, raw);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user