Fix improperly reading 2_10_10_10 bitfields (or so I hope)
Check at runtime if a vertex fetch index doesn't match gl_VertexID Fix trying to instantiate a vec1
This commit is contained in:
parent
b2d8837e52
commit
8a89a93eab
|
@ -209,18 +209,18 @@ vec3 get_10_11_11_s(const int data_in) {
|
||||||
|
|
||||||
vec4 get_2_10_10_10_u(const uint data_in) {
|
vec4 get_2_10_10_10_u(const uint data_in) {
|
||||||
vec4 vec;
|
vec4 vec;
|
||||||
vec.x = bitfieldExtract(data_in, 0, 10);
|
vec.w = bitfieldExtract(data_in, 0, 2 );
|
||||||
vec.y = bitfieldExtract(data_in, 10, 10);
|
vec.x = bitfieldExtract(data_in, 2, 10);
|
||||||
vec.z = bitfieldExtract(data_in, 20, 10);
|
vec.y = bitfieldExtract(data_in, 12, 10);
|
||||||
vec.w = bitfieldExtract(data_in, 30, 2 );
|
vec.z = bitfieldExtract(data_in, 22, 10);
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
vec4 get_2_10_10_10_s(const int data_in) {
|
vec4 get_2_10_10_10_s(const int data_in) {
|
||||||
vec4 vec;
|
vec4 vec;
|
||||||
vec.x = bitfieldExtract(data_in, 0, 10);
|
vec.w = bitfieldExtract(data_in, 0, 2 );
|
||||||
vec.y = bitfieldExtract(data_in, 10, 10);
|
vec.x = bitfieldExtract(data_in, 2, 10);
|
||||||
vec.z = bitfieldExtract(data_in, 20, 10);
|
vec.y = bitfieldExtract(data_in, 12, 10);
|
||||||
vec.w = bitfieldExtract(data_in, 30, 2 );
|
vec.z = bitfieldExtract(data_in, 22, 10);
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,6 +326,7 @@ void main() {
|
||||||
// Temporary registers.
|
// Temporary registers.
|
||||||
if (is_vertex_shader()) {
|
if (is_vertex_shader()) {
|
||||||
EmitSource(" vec4 r[64];\n");
|
EmitSource(" vec4 r[64];\n");
|
||||||
|
EmitSource(" r[0].x = gl_VertexID;\n");
|
||||||
} else {
|
} else {
|
||||||
// Bring interpolators from vertex shader into temporary registers.
|
// Bring interpolators from vertex shader into temporary registers.
|
||||||
EmitSource(" vec4 r[64];\n");
|
EmitSource(" vec4 r[64];\n");
|
||||||
|
@ -571,14 +572,6 @@ void GlslShaderTranslator::ProcessVertexFetchInstruction(
|
||||||
EmitSource("// ");
|
EmitSource("// ");
|
||||||
instr.Disassemble(&source_);
|
instr.Disassemble(&source_);
|
||||||
|
|
||||||
if (instr.operands[0].storage_index != 0) {
|
|
||||||
// Unimplemented for now.
|
|
||||||
EmitUnimplementedTranslationError();
|
|
||||||
EmitSourceDepth("pv.xyzw = vec4(0.0, 0.0, 0.0, 0.0);\n");
|
|
||||||
EmitStoreVectorResult(instr.result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instr.is_predicated) {
|
if (instr.is_predicated) {
|
||||||
EmitSourceDepth("if (%cp0) {\n", instr.predicate_condition ? ' ' : '!');
|
EmitSourceDepth("if (%cp0) {\n", instr.predicate_condition ? ' ' : '!');
|
||||||
Indent();
|
Indent();
|
||||||
|
@ -594,6 +587,9 @@ void GlslShaderTranslator::ProcessVertexFetchInstruction(
|
||||||
|
|
||||||
switch (instr.opcode) {
|
switch (instr.opcode) {
|
||||||
case FetchOpcode::kVertexFetch: {
|
case FetchOpcode::kVertexFetch: {
|
||||||
|
EmitSourceDepth("if (src0.x == gl_VertexID) {\n");
|
||||||
|
Indent();
|
||||||
|
|
||||||
EmitSourceDepth("pv.");
|
EmitSourceDepth("pv.");
|
||||||
for (int i = 0;
|
for (int i = 0;
|
||||||
i < GetVertexFormatComponentCount(instr.attributes.data_format);
|
i < GetVertexFormatComponentCount(instr.attributes.data_format);
|
||||||
|
@ -615,6 +611,16 @@ void GlslShaderTranslator::ProcessVertexFetchInstruction(
|
||||||
EmitSource(" = vf%u_%d;\n", instr.operands[1].storage_index,
|
EmitSource(" = vf%u_%d;\n", instr.operands[1].storage_index,
|
||||||
instr.attributes.offset);
|
instr.attributes.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unindent();
|
||||||
|
EmitSourceDepth("} else {\n");
|
||||||
|
Indent();
|
||||||
|
|
||||||
|
EmitSourceDepth("// UNIMPLEMENTED: Indexed fetch.\n");
|
||||||
|
EmitSourceDepth("pv = vec4(0.0, 0.0, 0.0, 1.0);\n");
|
||||||
|
|
||||||
|
Unindent();
|
||||||
|
EmitSourceDepth("}\n");
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
assert_always();
|
assert_always();
|
||||||
|
@ -918,7 +924,10 @@ void GlslShaderTranslator::EmitStoreResult(const InstructionResult& result,
|
||||||
EmitSource("clamp(");
|
EmitSource("clamp(");
|
||||||
}
|
}
|
||||||
if (has_const_writes) {
|
if (has_const_writes) {
|
||||||
|
if (component_write_count > 1) {
|
||||||
EmitSource("vec%d(", component_write_count);
|
EmitSource("vec%d(", component_write_count);
|
||||||
|
}
|
||||||
|
|
||||||
bool has_written = false;
|
bool has_written = false;
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (int j = 0; j < 4; ++j) {
|
||||||
if (result.write_mask[j]) {
|
if (result.write_mask[j]) {
|
||||||
|
@ -939,7 +948,10 @@ void GlslShaderTranslator::EmitStoreResult(const InstructionResult& result,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (component_write_count > 1) {
|
||||||
EmitSource(")");
|
EmitSource(")");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
EmitSource(temp);
|
EmitSource(temp);
|
||||||
if (!result.is_standard_swizzle()) {
|
if (!result.is_standard_swizzle()) {
|
||||||
|
|
Loading…
Reference in New Issue