aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp19
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp34
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.cpp1
3 files changed, 25 insertions, 29 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 1af4268a4..826eee7df 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -93,10 +93,6 @@ void oglEnable(GLenum cap, bool state) {
(state ? glEnable : glDisable)(cap);
}
-void oglEnablei(GLenum cap, bool state, GLuint index) {
- (state ? glEnablei : glDisablei)(cap, index);
-}
-
} // Anonymous namespace
RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWindow& emu_window,
@@ -478,7 +474,6 @@ void RasterizerOpenGL::Clear() {
void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
MICROPROFILE_SCOPE(OpenGL_Drawing);
auto& gpu = system.GPU().Maxwell3D();
- const auto& regs = gpu.regs;
query_cache.UpdateCounters();
@@ -529,7 +524,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
// Upload vertex and index data.
SetupVertexBuffer();
SetupVertexInstances();
- GLintptr index_buffer_offset;
+ GLintptr index_buffer_offset = 0;
if (is_indexed) {
index_buffer_offset = SetupIndexBuffer();
}
@@ -555,7 +550,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
ConfigureFramebuffers();
// Signal the buffer cache that we are not going to upload more things.
- const bool invalidate = buffer_cache.Unmap();
+ buffer_cache.Unmap();
// Now that we are no longer uploading data, we can safely bind the buffers to OpenGL.
vertex_array_pushbuffer.Bind();
@@ -938,13 +933,15 @@ void RasterizerOpenGL::SyncViewport() {
}
flags[Dirty::Viewport0 + i] = false;
- const Common::Rectangle<f32> rect{regs.viewport_transform[i].GetRect()};
+ const auto& src = regs.viewport_transform[i];
+ const Common::Rectangle<f32> rect{src.GetRect()};
glViewportIndexedf(static_cast<GLuint>(i), rect.left, rect.bottom, rect.GetWidth(),
rect.GetHeight());
- const auto& src = regs.viewports[i];
- glDepthRangeIndexed(static_cast<GLuint>(i), static_cast<GLdouble>(src.depth_range_near),
- static_cast<GLdouble>(src.depth_range_far));
+ const GLdouble reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
+ const GLdouble near_depth = src.translate_z - src.scale_z * reduce_z;
+ const GLdouble far_depth = src.translate_z + src.scale_z;
+ glDepthRangeIndexed(static_cast<GLuint>(i), near_depth, far_depth);
}
}
}
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 3adf7f0cb..2c38f57fd 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -393,10 +393,6 @@ std::string FlowStackTopName(MetaStackClass stack) {
return fmt::format("{}_flow_stack_top", GetFlowStackPrefix(stack));
}
-[[deprecated]] constexpr bool IsVertexShader(ShaderType stage) {
- return stage == ShaderType::Vertex;
-}
-
struct GenericVaryingDescription {
std::string name;
u8 first_element = 0;
@@ -529,8 +525,9 @@ private:
}
void DeclareVertex() {
- if (!IsVertexShader(stage))
+ if (stage != ShaderType::Vertex) {
return;
+ }
DeclareVertexRedeclarations();
}
@@ -602,14 +599,14 @@ private:
break;
}
}
- if (!IsVertexShader(stage) || device.HasVertexViewportLayer()) {
+ if (stage != ShaderType::Vertex || device.HasVertexViewportLayer()) {
if (ir.UsesLayer()) {
code.AddLine("int gl_Layer;");
}
if (ir.UsesViewportIndex()) {
code.AddLine("int gl_ViewportIndex;");
}
- } else if ((ir.UsesLayer() || ir.UsesViewportIndex()) && IsVertexShader(stage) &&
+ } else if ((ir.UsesLayer() || ir.UsesViewportIndex()) && stage == ShaderType::Vertex &&
!device.HasVertexViewportLayer()) {
LOG_ERROR(
Render_OpenGL,
@@ -1147,7 +1144,7 @@ private:
// TODO(Subv): Find out what the values are for the first two elements when inside a
// vertex shader, and what's the value of the fourth element when inside a Tess Eval
// shader.
- ASSERT(IsVertexShader(stage));
+ ASSERT(stage == ShaderType::Vertex);
switch (element) {
case 2:
// Config pack's first value is instance_id.
@@ -1218,12 +1215,12 @@ private:
UNIMPLEMENTED();
return {};
case 1:
- if (IsVertexShader(stage) && !device.HasVertexViewportLayer()) {
+ if (stage == ShaderType::Vertex && !device.HasVertexViewportLayer()) {
return {};
}
return {{"gl_Layer", Type::Int}};
case 2:
- if (IsVertexShader(stage) && !device.HasVertexViewportLayer()) {
+ if (stage == ShaderType::Vertex && !device.HasVertexViewportLayer()) {
return {};
}
return {{"gl_ViewportIndex", Type::Int}};
@@ -2009,16 +2006,19 @@ private:
expr += GetSampler(meta->sampler);
expr += ", ";
- expr += constructors.at(operation.GetOperandsCount() - 1);
+ expr += constructors.at(operation.GetOperandsCount() + (meta->array ? 1 : 0) - 1);
expr += '(';
for (std::size_t i = 0; i < count; ++i) {
- expr += VisitOperand(operation, i).AsInt();
- const std::size_t next = i + 1;
- if (next == count)
- expr += ')';
- else if (next < count)
+ if (i > 0) {
expr += ", ";
+ }
+ expr += VisitOperand(operation, i).AsInt();
}
+ if (meta->array) {
+ expr += ", ";
+ expr += Visit(meta->array).AsInt();
+ }
+ expr += ')';
if (meta->lod && !meta->sampler.IsBuffer()) {
expr += ", ";
@@ -2529,7 +2529,7 @@ private:
}
u32 GetNumPhysicalInputAttributes() const {
- return IsVertexShader(stage) ? GetNumPhysicalAttributes() : GetNumPhysicalVaryings();
+ return stage == ShaderType::Vertex ? GetNumPhysicalAttributes() : GetNumPhysicalVaryings();
}
u32 GetNumPhysicalAttributes() const {
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp
index 3f3bdf812..255ac3147 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.cpp
+++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp
@@ -238,7 +238,6 @@ void StateTracker::Initialize() {
SetupDirtyMisc(tables);
auto& store = dirty.on_write_stores;
- SetupCommonOnWriteStores(store);
store[VertexBuffers] = true;
for (std::size_t i = 0; i < Regs::NumVertexArrays; ++i) {
store[VertexBuffer0 + i] = true;