summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-22 20:00:41 -0400
committerGravatar bunnei2018-03-22 20:00:41 -0400
commitf707c2dac473c8971eccfd31d1b71281a039d95c (patch)
tree87a1ad073fcd1633112074a9f2b8eebda4c35079 /src
parentgpu: Expose Maxwell3D engine. (diff)
downloadyuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.gz
yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.tar.xz
yuzu-f707c2dac473c8971eccfd31d1b71281a039d95c.zip
gl_rasterizer: Add a simple passthrough shader in lieu of shader generation.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp59
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h14
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) {
54} 54}
55 55
56RasterizerOpenGL::RasterizerOpenGL() { 56RasterizerOpenGL::RasterizerOpenGL() {
57 shader_dirty = true;
58
57 has_ARB_buffer_storage = false; 59 has_ARB_buffer_storage = false;
58 has_ARB_direct_state_access = false; 60 has_ARB_direct_state_access = false;
59 has_ARB_separate_shader_objects = false; 61 has_ARB_separate_shader_objects = false;
@@ -106,8 +108,6 @@ RasterizerOpenGL::RasterizerOpenGL() {
106 state.draw.vertex_buffer = stream_buffer->GetHandle(); 108 state.draw.vertex_buffer = stream_buffer->GetHandle();
107 109
108 pipeline.Create(); 110 pipeline.Create();
109 vs_input_index_min = 0;
110 vs_input_index_max = 0;
111 state.draw.program_pipeline = pipeline.handle; 111 state.draw.program_pipeline = pipeline.handle;
112 state.draw.shader_program = 0; 112 state.draw.shader_program = 0;
113 state.draw.vertex_array = hw_vao.handle; 113 state.draw.vertex_array = hw_vao.handle;
@@ -233,7 +233,60 @@ bool RasterizerOpenGL::AccelerateDisplay(const void* config, PAddr framebuffer_a
233} 233}
234 234
235void RasterizerOpenGL::SetShader() { 235void RasterizerOpenGL::SetShader() {
236 UNIMPLEMENTED(); 236 // TODO(bunnei): The below sets up a static test shader for passing untransformed vertices to
237 // OpenGL for rendering. This should be removed/replaced when we start emulating Maxwell
238 // shaders.
239
240 static constexpr char vertex_shader[] = R"(
241#version 150 core
242
243in vec2 vert_position;
244in vec2 vert_tex_coord;
245out vec2 frag_tex_coord;
246
247void main() {
248 // Multiply input position by the rotscale part of the matrix and then manually translate by
249 // the last column. This is equivalent to using a full 3x3 matrix and expanding the vector
250 // to `vec3(vert_position.xy, 1.0)`
251 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);
252 frag_tex_coord = vert_tex_coord;
253}
254)";
255
256 static constexpr char fragment_shader[] = R"(
257#version 150 core
258
259in vec2 frag_tex_coord;
260out vec4 color;
261
262uniform sampler2D color_texture;
263
264void main() {
265 color = vec4(1.0, 0.0, 0.0, 1.0);
266}
267)";
268
269 if (current_shader) {
270 return;
271 }
272
273 LOG_ERROR(HW_GPU, "Emulated shaders are not supported! Using a passthrough shader.");
274
275 current_shader = &test_shader;
276 if (has_ARB_separate_shader_objects) {
277 test_shader.shader.Create(vertex_shader, nullptr, fragment_shader, {}, true);
278 glActiveShaderProgram(pipeline.handle, test_shader.shader.handle);
279 } else {
280 ASSERT_MSG(false, "Unimplemented");
281 }
282
283 state.draw.shader_program = test_shader.shader.handle;
284 state.Apply();
285
286 if (has_ARB_separate_shader_objects) {
287 state.draw.shader_program = 0;
288 state.Apply();
289 }
237} 290}
238 291
239void RasterizerOpenGL::SyncClipEnabled() { 292void 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:
42 ScreenInfo& screen_info) override; 42 ScreenInfo& screen_info) override;
43 bool AccelerateDrawBatch(bool is_indexed) override; 43 bool AccelerateDrawBatch(bool is_indexed) override;
44 44
45 /// OpenGL shader generated for a given Maxwell register state
46 struct MaxwellShader {
47 /// OpenGL shader resource
48 OGLShader shader;
49 };
50
45 struct VertexShader { 51 struct VertexShader {
46 OGLShader shader; 52 OGLShader shader;
47 }; 53 };
@@ -117,6 +123,12 @@ private:
117 123
118 RasterizerCacheOpenGL res_cache; 124 RasterizerCacheOpenGL res_cache;
119 125
126 /// Shader used for test renderering - to be removed once we have emulated shaders
127 MaxwellShader test_shader{};
128
129 const MaxwellShader* current_shader{};
130 bool shader_dirty{};
131
120 struct { 132 struct {
121 UniformData data; 133 UniformData data;
122 bool dirty; 134 bool dirty;
@@ -136,8 +148,6 @@ private:
136 static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024; 148 static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024;
137 std::unique_ptr<OGLStreamBuffer> stream_buffer; 149 std::unique_ptr<OGLStreamBuffer> stream_buffer;
138 150
139 GLint vs_input_index_min;
140 GLint vs_input_index_max;
141 GLsizeiptr vs_input_size; 151 GLsizeiptr vs_input_size;
142 152
143 void AnalyzeVertexArray(bool is_indexed); 153 void AnalyzeVertexArray(bool is_indexed);