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 /src/video_core/renderer_opengl/gl_rasterizer.cpp | |
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 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 59 |
1 files changed, 56 insertions, 3 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() { |