diff options
author | bunnei <bunneidev@gmail.com> | 2018-03-23 01:00:41 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-03-23 01:00:41 +0100 |
commit | f707c2dac473c8971eccfd31d1b71281a039d95c (patch) | |
tree | 87a1ad073fcd1633112074a9f2b8eebda4c35079 | |
parent | gpu: Expose Maxwell3D engine. (diff) | |
download | yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.gz yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.bz2 yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.lz yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.xz yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.zst yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 59 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 14 |
2 files changed, 68 insertions, 5 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 24cfff229..8b08de011 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -54,6 +54,8 @@ static void SetShaderUniformBlockBindings(GLuint shader) { } RasterizerOpenGL::RasterizerOpenGL() { + shader_dirty = true; + has_ARB_buffer_storage = false; has_ARB_direct_state_access = false; has_ARB_separate_shader_objects = false; @@ -106,8 +108,6 @@ RasterizerOpenGL::RasterizerOpenGL() { state.draw.vertex_buffer = stream_buffer->GetHandle(); pipeline.Create(); - vs_input_index_min = 0; - vs_input_index_max = 0; state.draw.program_pipeline = pipeline.handle; state.draw.shader_program = 0; state.draw.vertex_array = hw_vao.handle; @@ -233,7 +233,60 @@ bool RasterizerOpenGL::AccelerateDisplay(const void* config, PAddr framebuffer_a } void RasterizerOpenGL::SetShader() { - UNIMPLEMENTED(); + // TODO(bunnei): The below sets up a static test shader for passing untransformed vertices to + // OpenGL for rendering. This should be removed/replaced when we start emulating Maxwell + // shaders. + + static constexpr char vertex_shader[] = R"( +#version 150 core + +in vec2 vert_position; +in vec2 vert_tex_coord; +out vec2 frag_tex_coord; + +void main() { + // Multiply input position by the rotscale part of the matrix and then manually translate by + // the last column. This is equivalent to using a full 3x3 matrix and expanding the vector + // to `vec3(vert_position.xy, 1.0)` + gl_Position = vec4(mat2(mat3x2(0.0015625f, 0.0, 0.0, -0.0027778, -1.0, 1.0)) * vert_position + mat3x2(0.0015625f, 0.0, 0.0, -0.0027778, -1.0, 1.0)[2], 0.0, 1.0); + frag_tex_coord = vert_tex_coord; +} +)"; + + static constexpr char fragment_shader[] = R"( +#version 150 core + +in vec2 frag_tex_coord; +out vec4 color; + +uniform sampler2D color_texture; + +void main() { + color = vec4(1.0, 0.0, 0.0, 1.0); +} +)"; + + if (current_shader) { + return; + } + + LOG_ERROR(HW_GPU, "Emulated shaders are not supported! Using a passthrough shader."); + + current_shader = &test_shader; + if (has_ARB_separate_shader_objects) { + test_shader.shader.Create(vertex_shader, nullptr, fragment_shader, {}, true); + glActiveShaderProgram(pipeline.handle, test_shader.shader.handle); + } else { + ASSERT_MSG(false, "Unimplemented"); + } + + state.draw.shader_program = test_shader.shader.handle; + state.Apply(); + + if (has_ARB_separate_shader_objects) { + state.draw.shader_program = 0; + state.Apply(); + } } void RasterizerOpenGL::SyncClipEnabled() { diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 893fc530f..7a68480d9 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -42,6 +42,12 @@ public: ScreenInfo& screen_info) override; bool AccelerateDrawBatch(bool is_indexed) override; + /// OpenGL shader generated for a given Maxwell register state + struct MaxwellShader { + /// OpenGL shader resource + OGLShader shader; + }; + struct VertexShader { OGLShader shader; }; @@ -117,6 +123,12 @@ private: RasterizerCacheOpenGL res_cache; + /// Shader used for test renderering - to be removed once we have emulated shaders + MaxwellShader test_shader{}; + + const MaxwellShader* current_shader{}; + bool shader_dirty{}; + struct { UniformData data; bool dirty; @@ -136,8 +148,6 @@ private: static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024; std::unique_ptr<OGLStreamBuffer> stream_buffer; - GLint vs_input_index_min; - GLint vs_input_index_max; GLsizeiptr vs_input_size; void AnalyzeVertexArray(bool is_indexed); |