Private->Function variables, fragment output, geometry shader tweaks.
This commit is contained in:
parent
1e87d1fa7f
commit
ff373a83a4
|
@ -83,19 +83,19 @@ void SpirvShaderTranslator::StartTranslation() {
|
|||
|
||||
registers_type_ =
|
||||
b.makeArrayType(vec4_float_type_, b.makeUintConstant(64), 0);
|
||||
registers_ptr_ = b.createVariable(spv::StorageClass::StorageClassPrivate,
|
||||
registers_ptr_ = b.createVariable(spv::StorageClass::StorageClassFunction,
|
||||
registers_type_, "r");
|
||||
|
||||
aL_ = b.createVariable(spv::StorageClass::StorageClassPrivate,
|
||||
aL_ = b.createVariable(spv::StorageClass::StorageClassFunction,
|
||||
vec4_uint_type_, "aL");
|
||||
|
||||
p0_ = b.createVariable(spv::StorageClass::StorageClassPrivate, bool_type_,
|
||||
p0_ = b.createVariable(spv::StorageClass::StorageClassFunction, bool_type_,
|
||||
"p0");
|
||||
ps_ = b.createVariable(spv::StorageClass::StorageClassPrivate, float_type_,
|
||||
ps_ = b.createVariable(spv::StorageClass::StorageClassFunction, float_type_,
|
||||
"ps");
|
||||
pv_ = b.createVariable(spv::StorageClass::StorageClassPrivate,
|
||||
pv_ = b.createVariable(spv::StorageClass::StorageClassFunction,
|
||||
vec4_float_type_, "pv");
|
||||
a0_ = b.createVariable(spv::StorageClass::StorageClassPrivate,
|
||||
a0_ = b.createVariable(spv::StorageClass::StorageClassFunction,
|
||||
b.makeUintType(32), "a0");
|
||||
|
||||
// Uniform constants.
|
||||
|
@ -110,7 +110,7 @@ void SpirvShaderTranslator::StartTranslation() {
|
|||
{float_consts_type, loop_consts_type, bool_consts_type}, "consts_type");
|
||||
b.addDecoration(consts_struct_type, spv::Decoration::DecorationBlock);
|
||||
|
||||
// Constants member decorations
|
||||
// Constants member decorations.
|
||||
b.addMemberDecoration(consts_struct_type, 0,
|
||||
spv::Decoration::DecorationOffset, 0);
|
||||
b.addMemberDecoration(consts_struct_type, 0,
|
||||
|
@ -144,11 +144,11 @@ void SpirvShaderTranslator::StartTranslation() {
|
|||
b.addDecoration(consts_, spv::Decoration::DecorationBinding, 1);
|
||||
}
|
||||
|
||||
// Interpolators
|
||||
// Interpolators.
|
||||
Id interpolators_type =
|
||||
b.makeArrayType(vec4_float_type_, b.makeUintConstant(16), 0);
|
||||
if (is_vertex_shader()) {
|
||||
// Vertex inputs/outputs
|
||||
// Vertex inputs/outputs.
|
||||
for (const auto& binding : vertex_bindings()) {
|
||||
for (const auto& attrib : binding.attributes) {
|
||||
Id attrib_type = 0;
|
||||
|
@ -204,13 +204,22 @@ void SpirvShaderTranslator::StartTranslation() {
|
|||
b.addDecoration(pos_, spv::Decoration::DecorationBuiltIn,
|
||||
spv::BuiltIn::BuiltInPosition);
|
||||
} else {
|
||||
// Pixel inputs/outputs
|
||||
// Pixel inputs from vertex shader.
|
||||
interpolators_ = b.createVariable(spv::StorageClass::StorageClassInput,
|
||||
interpolators_type, "interpolators");
|
||||
b.addDecoration(interpolators_, spv::Decoration::DecorationNoPerspective);
|
||||
b.addDecoration(interpolators_, spv::Decoration::DecorationLocation, 0);
|
||||
|
||||
// Copy interpolators to r[0..16]
|
||||
// Pixel fragment outputs (one per render target).
|
||||
Id frag_outputs_type =
|
||||
b.makeArrayType(vec4_float_type_, b.makeUintConstant(4), 0);
|
||||
frag_outputs_ = b.createVariable(spv::StorageClass::StorageClassOutput,
|
||||
frag_outputs_type, "o");
|
||||
b.addDecoration(frag_outputs_, spv::Decoration::DecorationLocation, 0);
|
||||
|
||||
// TODO(benvanik): frag depth, etc.
|
||||
|
||||
// Copy interpolators to r[0..16].
|
||||
b.createNoResultOp(spv::Op::OpCopyMemorySized,
|
||||
{registers_ptr_, interpolators_,
|
||||
b.makeUintConstant(16 * 4 * sizeof(float))});
|
||||
|
@ -916,7 +925,7 @@ Id SpirvShaderTranslator::LoadFromOperand(const InstructionOperand& op) {
|
|||
switch (op.storage_source) {
|
||||
case InstructionStorageSource::kRegister:
|
||||
storage_pointer = registers_ptr_;
|
||||
storage_class = spv::StorageClass::StorageClassPrivate;
|
||||
storage_class = spv::StorageClass::StorageClassFunction;
|
||||
storage_type = vec4_float_type_;
|
||||
storage_offsets.push_back(storage_index);
|
||||
break;
|
||||
|
@ -1040,7 +1049,7 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
|||
switch (result.storage_target) {
|
||||
case InstructionStorageTarget::kRegister:
|
||||
storage_pointer = registers_ptr_;
|
||||
storage_class = spv::StorageClass::StorageClassPrivate;
|
||||
storage_class = spv::StorageClass::StorageClassFunction;
|
||||
storage_type = vec4_float_type_;
|
||||
storage_offsets.push_back(storage_index);
|
||||
storage_array = true;
|
||||
|
@ -1068,7 +1077,12 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
|||
break;
|
||||
case InstructionStorageTarget::kColorTarget:
|
||||
assert_true(is_pixel_shader());
|
||||
// TODO(benvanik): result.storage_index
|
||||
assert_not_zero(frag_outputs_);
|
||||
storage_pointer = frag_outputs_;
|
||||
storage_class = spv::StorageClass::StorageClassOutput;
|
||||
storage_type = vec4_float_type_;
|
||||
storage_offsets.push_back(storage_index);
|
||||
storage_array = true;
|
||||
break;
|
||||
case InstructionStorageTarget::kDepth:
|
||||
assert_true(is_pixel_shader());
|
||||
|
|
|
@ -54,8 +54,6 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
|||
void ProcessAluInstruction(const ParsedAluInstruction& instr) override;
|
||||
|
||||
private:
|
||||
void SetupPushConstants();
|
||||
|
||||
void ProcessVectorAluInstruction(const ParsedAluInstruction& instr);
|
||||
void ProcessScalarAluInstruction(const ParsedAluInstruction& instr);
|
||||
|
||||
|
@ -80,22 +78,23 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
|||
std::unique_ptr<spv::Builder> builder_;
|
||||
spv::Id glsl_std_450_instruction_set_ = 0;
|
||||
|
||||
// Types
|
||||
// Types.
|
||||
spv::Id float_type_ = 0, bool_type_ = 0;
|
||||
spv::Id vec2_float_type_ = 0, vec3_float_type_ = 0, vec4_float_type_ = 0;
|
||||
spv::Id vec4_uint_type_ = 0;
|
||||
spv::Id vec4_bool_type_ = 0;
|
||||
|
||||
// Constants
|
||||
// Constants.
|
||||
spv::Id vec4_float_zero_ = 0, vec4_float_one_ = 0;
|
||||
|
||||
// Array of AMD registers
|
||||
// Array of AMD registers.
|
||||
// These values are all pointers.
|
||||
spv::Id registers_ptr_ = 0, registers_type_ = 0;
|
||||
spv::Id consts_ = 0, a0_ = 0, aL_ = 0, p0_ = 0;
|
||||
spv::Id ps_ = 0, pv_ = 0; // IDs of previous results
|
||||
spv::Id pos_ = 0;
|
||||
spv::Id interpolators_ = 0;
|
||||
spv::Id frag_outputs_ = 0;
|
||||
|
||||
// Map of {binding -> {offset -> spv input}}
|
||||
std::map<uint32_t, std::map<uint32_t, spv::Id>> vertex_binding_map_;
|
||||
|
|
|
@ -62,12 +62,12 @@ const uint8_t line_quad_list_geom[] = {
|
|||
0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00,
|
||||
0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
|
||||
0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
|
|
Binary file not shown.
|
@ -42,10 +42,10 @@
|
|||
OpMemberDecorate %16 1 BuiltIn PointSize
|
||||
OpMemberDecorate %16 2 BuiltIn ClipDistance
|
||||
OpDecorate %16 Block
|
||||
OpMemberDecorate %34 0 Location 1
|
||||
OpMemberDecorate %34 0 Location 0
|
||||
OpDecorate %34 Stream 0
|
||||
OpDecorate %36 Stream 0
|
||||
OpMemberDecorate %37 0 Location 1
|
||||
OpMemberDecorate %37 0 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeFloat 32
|
||||
|
|
|
@ -67,12 +67,12 @@ const uint8_t point_list_geom[] = {
|
|||
0x27, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x00, 0x04, 0x00, 0x4A, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4C, 0x00, 0x00, 0x00,
|
||||
0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
|
||||
0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
|
|
Binary file not shown.
|
@ -46,10 +46,10 @@
|
|||
OpDecorate %39 Block
|
||||
OpDecorate %39 Stream 0
|
||||
OpDecorate %41 Stream 0
|
||||
OpMemberDecorate %74 0 Location 1
|
||||
OpMemberDecorate %74 0 Location 0
|
||||
OpDecorate %74 Stream 0
|
||||
OpDecorate %76 Stream 0
|
||||
OpMemberDecorate %77 0 Location 1
|
||||
OpMemberDecorate %77 0 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeFloat 32
|
||||
|
|
|
@ -67,11 +67,11 @@ const uint8_t quad_list_geom[] = {
|
|||
0x0B, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
|
||||
0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
|
||||
0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x39, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x39, 0x00, 0x00, 0x00,
|
||||
0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
|
||||
0x3B, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x48, 0x00, 0x05, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
|
||||
0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
|
||||
|
|
Binary file not shown.
|
@ -45,10 +45,10 @@
|
|||
OpMemberDecorate %39 1 BuiltIn PointSize
|
||||
OpMemberDecorate %39 2 BuiltIn ClipDistance
|
||||
OpDecorate %39 Block
|
||||
OpMemberDecorate %57 0 Location 1
|
||||
OpMemberDecorate %57 0 Location 0
|
||||
OpDecorate %57 Stream 0
|
||||
OpDecorate %59 Stream 0
|
||||
OpMemberDecorate %60 0 Location 1
|
||||
OpMemberDecorate %60 0 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeInt 32 1
|
||||
|
|
|
@ -66,12 +66,12 @@ const uint8_t rect_list_geom[] = {
|
|||
0x20, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x00, 0x04, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00,
|
||||
0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
|
||||
0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x14, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
|
|
Binary file not shown.
|
@ -45,10 +45,10 @@
|
|||
OpDecorate %32 Block
|
||||
OpDecorate %32 Stream 0
|
||||
OpDecorate %34 Stream 0
|
||||
OpMemberDecorate %47 0 Location 1
|
||||
OpMemberDecorate %47 0 Location 0
|
||||
OpDecorate %47 Stream 0
|
||||
OpDecorate %49 Stream 0
|
||||
OpMemberDecorate %50 0 Location 1
|
||||
OpMemberDecorate %50 0 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeBool
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// NOTE: This file is compiled and embedded into the exe.
|
||||
// Use `xenia-build genspirv` and check in any changes under bin/.
|
||||
|
||||
#version 450
|
||||
#version 450 core
|
||||
#extension all : warn
|
||||
|
||||
in gl_PerVertex {
|
||||
|
@ -19,8 +19,8 @@ out gl_PerVertex {
|
|||
struct VertexData {
|
||||
vec4 o[16];
|
||||
};
|
||||
layout(location = 1) in VertexData in_vtx[];
|
||||
layout(location = 1) out VertexData out_vtx;
|
||||
layout(location = 0) in VertexData in_vtx[];
|
||||
layout(location = 0) out VertexData out_vtx;
|
||||
|
||||
layout(lines_adjacency) in;
|
||||
layout(line_strip, max_vertices = 5) out;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// NOTE: This file is compiled and embedded into the exe.
|
||||
// Use `xenia-build genspirv` and check in any changes under bin/.
|
||||
|
||||
#version 450
|
||||
#version 450 core
|
||||
#extension all : warn
|
||||
|
||||
in gl_PerVertex {
|
||||
|
@ -19,8 +19,8 @@ out gl_PerVertex {
|
|||
struct VertexData {
|
||||
vec4 o[16];
|
||||
};
|
||||
layout(location = 1) in VertexData in_vtx[];
|
||||
layout(location = 1) out VertexData out_vtx;
|
||||
layout(location = 0) in VertexData in_vtx[];
|
||||
layout(location = 0) out VertexData out_vtx;
|
||||
|
||||
// TODO(benvanik): fetch default point size from register and use that if
|
||||
// the VS doesn't write oPointSize.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// NOTE: This file is compiled and embedded into the exe.
|
||||
// Use `xenia-build genspirv` and check in any changes under bin/.
|
||||
|
||||
#version 450
|
||||
#version 450 core
|
||||
#extension all : warn
|
||||
|
||||
in gl_PerVertex {
|
||||
|
@ -19,8 +19,8 @@ out gl_PerVertex {
|
|||
struct VertexData {
|
||||
vec4 o[16];
|
||||
};
|
||||
layout(location = 1) in VertexData in_vtx[];
|
||||
layout(location = 1) out VertexData out_vtx;
|
||||
layout(location = 0) in VertexData in_vtx[];
|
||||
layout(location = 0) out VertexData out_vtx;
|
||||
|
||||
layout(lines_adjacency) in;
|
||||
layout(triangle_strip, max_vertices = 4) out;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// NOTE: This file is compiled and embedded into the exe.
|
||||
// Use `xenia-build genspirv` and check in any changes under bin/.
|
||||
|
||||
#version 450
|
||||
#version 450 core
|
||||
#extension all : warn
|
||||
|
||||
in gl_PerVertex {
|
||||
|
@ -19,8 +19,8 @@ out gl_PerVertex {
|
|||
struct VertexData {
|
||||
vec4 o[16];
|
||||
};
|
||||
layout(location = 1) in VertexData in_vtx[];
|
||||
layout(location = 1) out VertexData out_vtx;
|
||||
layout(location = 0) in VertexData in_vtx[];
|
||||
layout(location = 0) out VertexData out_vtx;
|
||||
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices = 6) out;
|
||||
|
|
Loading…
Reference in New Issue