diff options
3 files changed, 31 insertions, 18 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 16e2a8502..d5424301b 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -179,8 +179,12 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 179 | const char swizzle{"xyzw"[element]}; | 179 | const char swizzle{"xyzw"[element]}; |
| 180 | if (IR::IsGeneric(attr)) { | 180 | if (IR::IsGeneric(attr)) { |
| 181 | const u32 index{IR::GenericAttributeIndex(attr)}; | 181 | const u32 index{IR::GenericAttributeIndex(attr)}; |
| 182 | if (!ctx.runtime_info.previous_stage_stores.Generic(index)) { | 182 | if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) { |
| 183 | ctx.AddF32("{}=0.f;", inst, attr); | 183 | if (element == 3) { |
| 184 | ctx.AddF32("{}=1.f;", inst, attr); | ||
| 185 | } else { | ||
| 186 | ctx.AddF32("{}=0.f;", inst, attr); | ||
| 187 | } | ||
| 184 | return; | 188 | return; |
| 185 | } | 189 | } |
| 186 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); | 190 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 77fbb2b2f..756de0a27 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -298,10 +298,14 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 298 | if (IR::IsGeneric(attr)) { | 298 | if (IR::IsGeneric(attr)) { |
| 299 | const u32 index{IR::GenericAttributeIndex(attr)}; | 299 | const u32 index{IR::GenericAttributeIndex(attr)}; |
| 300 | const std::optional<AttrInfo> type{AttrTypes(ctx, index)}; | 300 | const std::optional<AttrInfo> type{AttrTypes(ctx, index)}; |
| 301 | if (!type || !ctx.runtime_info.previous_stage_stores.Generic(index)) { | 301 | if (!type) { |
| 302 | // Attribute is disabled | 302 | // Attribute is disabled |
| 303 | return ctx.Const(0.0f); | 303 | return ctx.Const(0.0f); |
| 304 | } | 304 | } |
| 305 | if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) { | ||
| 306 | // Varying component is not written | ||
| 307 | return ctx.Const(type && element == 3 ? 1.0f : 0.0f); | ||
| 308 | } | ||
| 305 | const Id generic_id{ctx.input_generics.at(index)}; | 309 | const Id generic_id{ctx.input_generics.at(index)}; |
| 306 | const Id pointer{AttrPointer(ctx, type->pointer, vertex, generic_id, ctx.Const(element))}; | 310 | const Id pointer{AttrPointer(ctx, type->pointer, vertex, generic_id, ctx.Const(element))}; |
| 307 | const Id value{ctx.OpLoad(type->id, pointer)}; | 311 | const Id value{ctx.OpLoad(type->id, pointer)}; |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index b8777643b..dab0afe6d 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -140,6 +140,26 @@ RendererOpenGL::RendererOpenGL(Core::TelemetrySession& telemetry_session_, | |||
| 140 | } | 140 | } |
| 141 | AddTelemetryFields(); | 141 | AddTelemetryFields(); |
| 142 | InitOpenGLObjects(); | 142 | InitOpenGLObjects(); |
| 143 | |||
| 144 | // Initialize default attributes to match hardware's disabled attributes | ||
| 145 | GLint max_attribs{}; | ||
| 146 | glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs); | ||
| 147 | for (GLint attrib = 0; attrib < max_attribs; ++attrib) { | ||
| 148 | glVertexAttrib4f(attrib, 0.0f, 0.0f, 0.0f, 0.0f); | ||
| 149 | } | ||
| 150 | // Enable seamless cubemaps when per texture parameters are not available | ||
| 151 | if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) { | ||
| 152 | glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); | ||
| 153 | } | ||
| 154 | // Enable unified vertex attributes and query vertex buffer address when the driver supports it | ||
| 155 | if (device.HasVertexBufferUnifiedMemory()) { | ||
| 156 | glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV); | ||
| 157 | glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV); | ||
| 158 | |||
| 159 | glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY); | ||
| 160 | glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV, | ||
| 161 | &vertex_buffer_address); | ||
| 162 | } | ||
| 143 | } | 163 | } |
| 144 | 164 | ||
| 145 | RendererOpenGL::~RendererOpenGL() = default; | 165 | RendererOpenGL::~RendererOpenGL() = default; |
| @@ -256,21 +276,6 @@ void RendererOpenGL::InitOpenGLObjects() { | |||
| 256 | 276 | ||
| 257 | // Clear screen to black | 277 | // Clear screen to black |
| 258 | LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture); | 278 | LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture); |
| 259 | |||
| 260 | // Enable seamless cubemaps when per texture parameters are not available | ||
| 261 | if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) { | ||
| 262 | glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); | ||
| 263 | } | ||
| 264 | |||
| 265 | // Enable unified vertex attributes and query vertex buffer address when the driver supports it | ||
| 266 | if (device.HasVertexBufferUnifiedMemory()) { | ||
| 267 | glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV); | ||
| 268 | glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV); | ||
| 269 | |||
| 270 | glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY); | ||
| 271 | glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV, | ||
| 272 | &vertex_buffer_address); | ||
| 273 | } | ||
| 274 | } | 279 | } |
| 275 | 280 | ||
| 276 | void RendererOpenGL::AddTelemetryFields() { | 281 | void RendererOpenGL::AddTelemetryFields() { |