diff options
| author | 2018-05-30 10:58:03 -0500 | |
|---|---|---|
| committer | 2018-05-30 10:58:03 -0500 | |
| commit | 99f12b05fa19e46d2dd482c6bde954046f5fd5bd (patch) | |
| tree | 01657f3bbad78505ac27115a3e8e7979e97b4a6a /src | |
| parent | Merge pull request #480 from mailwl/bcat (diff) | |
| download | yuzu-99f12b05fa19e46d2dd482c6bde954046f5fd5bd.tar.gz yuzu-99f12b05fa19e46d2dd482c6bde954046f5fd5bd.tar.xz yuzu-99f12b05fa19e46d2dd482c6bde954046f5fd5bd.zip | |
Shaders: Implemented reading the gl_InstanceID and gl_VertexID variables in the vertex shader.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index d75de85e2..e115575ca 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -75,6 +75,10 @@ union Attribute { | |||
| 75 | enum class Index : u64 { | 75 | enum class Index : u64 { |
| 76 | Position = 7, | 76 | Position = 7, |
| 77 | Attribute_0 = 8, | 77 | Attribute_0 = 8, |
| 78 | // This attribute contains a tuple of (~, ~, InstanceId, VertexId) when inside a vertex | ||
| 79 | // shader, and a tuple of (TessCoord.x, TessCoord.y, TessCoord.z, ~) when inside a Tess Eval | ||
| 80 | // shader. | ||
| 81 | TessCoordInstanceIDVertexID = 47, | ||
| 78 | }; | 82 | }; |
| 79 | 83 | ||
| 80 | union { | 84 | union { |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 75822e750..9bbdea419 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -299,7 +299,7 @@ public: | |||
| 299 | * are stored as floats, so this may require conversion. | 299 | * are stored as floats, so this may require conversion. |
| 300 | * @param reg The destination register to use. | 300 | * @param reg The destination register to use. |
| 301 | * @param elem The element to use for the operation. | 301 | * @param elem The element to use for the operation. |
| 302 | * @param attribute The input attibute to use as the source value. | 302 | * @param attribute The input attribute to use as the source value. |
| 303 | */ | 303 | */ |
| 304 | void SetRegisterToInputAttibute(const Register& reg, u64 elem, Attribute::Index attribute) { | 304 | void SetRegisterToInputAttibute(const Register& reg, u64 elem, Attribute::Index attribute) { |
| 305 | std::string dest = GetRegisterAsFloat(reg); | 305 | std::string dest = GetRegisterAsFloat(reg); |
| @@ -451,6 +451,12 @@ private: | |||
| 451 | switch (attribute) { | 451 | switch (attribute) { |
| 452 | case Attribute::Index::Position: | 452 | case Attribute::Index::Position: |
| 453 | return "position"; | 453 | return "position"; |
| 454 | case Attribute::Index::TessCoordInstanceIDVertexID: | ||
| 455 | // TODO(Subv): Find out what the values are for the first two elements when inside a | ||
| 456 | // vertex shader, and what's the value of the fourth element when inside a Tess Eval | ||
| 457 | // shader. | ||
| 458 | ASSERT(stage == Maxwell3D::Regs::ShaderStage::Vertex); | ||
| 459 | return "vec4(0, 0, gl_InstanceID, gl_VertexID)"; | ||
| 454 | default: | 460 | default: |
| 455 | const u32 index{static_cast<u32>(attribute) - | 461 | const u32 index{static_cast<u32>(attribute) - |
| 456 | static_cast<u32>(Attribute::Index::Attribute_0)}; | 462 | static_cast<u32>(Attribute::Index::Attribute_0)}; |