From b5eb3905cdad545fc2c4c3141d0d3ff22183e442 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Jul 2018 12:08:10 -0400 Subject: gl_rasterizer: Use in-class member initializers where applicable We can just assign to the members directly in these cases. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 7 ------- src/video_core/renderer_opengl/gl_rasterizer.h | 10 +++++----- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src/video_core/renderer_opengl') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 5d5ad84b7..d2ac067c0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -37,11 +37,6 @@ MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); RasterizerOpenGL::RasterizerOpenGL() { - has_ARB_buffer_storage = false; - has_ARB_direct_state_access = false; - has_ARB_separate_shader_objects = false; - has_ARB_vertex_attrib_binding = false; - // Create sampler objects for (size_t i = 0; i < texture_samplers.size(); ++i) { texture_samplers[i].Create(); @@ -110,8 +105,6 @@ RasterizerOpenGL::RasterizerOpenGL() { glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer.handle); } - accelerate_draw = AccelDraw::Disabled; - glEnable(GL_BLEND); LOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!"); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index ab06e2d95..e150be58f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -135,10 +135,10 @@ private: /// Syncs the blend state to match the guest state void SyncBlendState(); - bool has_ARB_buffer_storage; - bool has_ARB_direct_state_access; - bool has_ARB_separate_shader_objects; - bool has_ARB_vertex_attrib_binding; + bool has_ARB_buffer_storage = false; + bool has_ARB_direct_state_access = false; + bool has_ARB_separate_shader_objects = false; + bool has_ARB_vertex_attrib_binding = false; OpenGLState state; @@ -167,5 +167,5 @@ private: void SetupShaders(u8* buffer_ptr, GLintptr buffer_offset); enum class AccelDraw { Disabled, Arrays, Indexed }; - AccelDraw accelerate_draw; + AccelDraw accelerate_draw = AccelDraw::Disabled; }; -- cgit v1.2.3 From 16139ed53b1b4be3ffc985b84ad966c8920082d4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Jul 2018 12:10:35 -0400 Subject: gl_rasterizer: Use std::string_view instead of std::string when checking for extensions We can avoid heap allocations here by just using a std::string_view instead of performing unnecessary copying of the string data. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/video_core/renderer_opengl') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d2ac067c0..f45fbbcd4 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,8 @@ RasterizerOpenGL::RasterizerOpenGL() { GLint ext_num; glGetIntegerv(GL_NUM_EXTENSIONS, &ext_num); for (GLint i = 0; i < ext_num; i++) { - std::string extension{reinterpret_cast(glGetStringi(GL_EXTENSIONS, i))}; + const std::string_view extension{ + reinterpret_cast(glGetStringi(GL_EXTENSIONS, i))}; if (extension == "GL_ARB_buffer_storage") { has_ARB_buffer_storage = true; -- cgit v1.2.3 From 0162f8b3a74498f9ecf974594266239744d3187c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Jul 2018 12:19:39 -0400 Subject: gl_rasterizer: Replace magic number with GL_INVALID_INDEX in SetupConstBuffers() This is just the named constant that OpenGL provides, so we can use that instead of using a literal -1 --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/video_core/renderer_opengl') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f45fbbcd4..a1c47bae9 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -689,10 +689,12 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr glBindBuffer(GL_UNIFORM_BUFFER, 0); // Now configure the bindpoint of the buffer inside the shader - std::string buffer_name = used_buffer.GetName(); - GLuint index = glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str()); - if (index != -1) + const std::string buffer_name = used_buffer.GetName(); + const GLuint index = + glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str()); + if (index != GL_INVALID_INDEX) { glUniformBlockBinding(program, index, buffer_draw_state.bindpoint); + } } state.Apply(); -- cgit v1.2.3