diff options
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | 46 | ||||
| -rw-r--r-- | src/shader_recompiler/profile.h | 2 |
4 files changed, 39 insertions, 13 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index f0e9dffc2..d0880bdcb 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -384,7 +384,7 @@ void EmitContext::SetupExtensions() { | |||
| 384 | profile.support_viewport_index_layer_non_geometry && stage != Stage::Geometry) { | 384 | profile.support_viewport_index_layer_non_geometry && stage != Stage::Geometry) { |
| 385 | header += "#extension GL_ARB_shader_viewport_layer_array : enable\n"; | 385 | header += "#extension GL_ARB_shader_viewport_layer_array : enable\n"; |
| 386 | } | 386 | } |
| 387 | if (info.uses_sparse_residency) { | 387 | if (info.uses_sparse_residency && profile.support_gl_sparse_textures) { |
| 388 | header += "#extension GL_ARB_sparse_texture2 : enable\n"; | 388 | header += "#extension GL_ARB_sparse_texture2 : enable\n"; |
| 389 | } | 389 | } |
| 390 | if (info.stores_viewport_mask && profile.support_viewport_mask) { | 390 | if (info.stores_viewport_mask && profile.support_viewport_mask) { |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index d76b63b2d..6d64913bb 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -215,7 +215,7 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR | |||
| 215 | ctx.header += | 215 | ctx.header += |
| 216 | fmt::format("shared uint smem[{}];", Common::AlignUp(program.shared_memory_size, 4)); | 216 | fmt::format("shared uint smem[{}];", Common::AlignUp(program.shared_memory_size, 4)); |
| 217 | } | 217 | } |
| 218 | ctx.header += "\nvoid main(){\n"; | 218 | ctx.header += "void main(){\n"; |
| 219 | if (program.stage == Stage::VertexA || program.stage == Stage::VertexB) { | 219 | if (program.stage == Stage::VertexA || program.stage == Stage::VertexB) { |
| 220 | ctx.header += "gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);"; | 220 | ctx.header += "gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);"; |
| 221 | // TODO: Properly resolve attribute issues | 221 | // TODO: Properly resolve attribute issues |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index 51181d1c1..c6b3df9c9 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -94,7 +94,11 @@ std::string GetOffsetVec(EmitContext& ctx, const IR::Value& offset) { | |||
| 94 | break; | 94 | break; |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | const auto offset_str{ctx.var_alloc.Consume(offset)}; | 97 | const bool has_var_aoffi{ctx.profile.support_gl_variable_aoffi}; |
| 98 | if (!has_var_aoffi) { | ||
| 99 | // LOG_WARNING("Device does not support variable texture offsets, STUBBING"); | ||
| 100 | } | ||
| 101 | const auto offset_str{has_var_aoffi ? ctx.var_alloc.Consume(offset) : "0"}; | ||
| 98 | switch (offset.Type()) { | 102 | switch (offset.Type()) { |
| 99 | case IR::Type::U32: | 103 | case IR::Type::U32: |
| 100 | return fmt::format("int({})", offset_str); | 104 | return fmt::format("int({})", offset_str); |
| @@ -146,7 +150,12 @@ void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu | |||
| 146 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; | 150 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; |
| 147 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 151 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 148 | const auto sparse_inst{PrepareSparse(inst)}; | 152 | const auto sparse_inst{PrepareSparse(inst)}; |
| 149 | if (!sparse_inst) { | 153 | const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; |
| 154 | if (sparse_inst && !supports_sparse) { | ||
| 155 | // LOG_WARNING(..., "Device does not support sparse texture queries. STUBBING"); | ||
| 156 | ctx.AddU1("{}=true;", *sparse_inst); | ||
| 157 | } | ||
| 158 | if (!sparse_inst || !supports_sparse) { | ||
| 150 | if (!offset.IsEmpty()) { | 159 | if (!offset.IsEmpty()) { |
| 151 | const auto offset_str{GetOffsetVec(ctx, offset)}; | 160 | const auto offset_str{GetOffsetVec(ctx, offset)}; |
| 152 | if (ctx.stage == Stage::Fragment) { | 161 | if (ctx.stage == Stage::Fragment) { |
| @@ -163,7 +172,6 @@ void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu | |||
| 163 | } | 172 | } |
| 164 | return; | 173 | return; |
| 165 | } | 174 | } |
| 166 | // TODO: Query sparseTexels extension support | ||
| 167 | if (!offset.IsEmpty()) { | 175 | if (!offset.IsEmpty()) { |
| 168 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureOffsetARB({},{},{},{}{}));", | 176 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureOffsetARB({},{},{},{}{}));", |
| 169 | *sparse_inst, texture, coords, GetOffsetVec(ctx, offset), texel, bias); | 177 | *sparse_inst, texture, coords, GetOffsetVec(ctx, offset), texel, bias); |
| @@ -186,7 +194,12 @@ void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu | |||
| 186 | const auto texture{Texture(ctx, info, index)}; | 194 | const auto texture{Texture(ctx, info, index)}; |
| 187 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 195 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 188 | const auto sparse_inst{PrepareSparse(inst)}; | 196 | const auto sparse_inst{PrepareSparse(inst)}; |
| 189 | if (!sparse_inst) { | 197 | const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; |
| 198 | if (sparse_inst && !supports_sparse) { | ||
| 199 | // LOG_WARNING(..., "Device does not support sparse texture queries. STUBBING"); | ||
| 200 | ctx.AddU1("{}=true;", *sparse_inst); | ||
| 201 | } | ||
| 202 | if (!sparse_inst || !supports_sparse) { | ||
| 190 | if (!offset.IsEmpty()) { | 203 | if (!offset.IsEmpty()) { |
| 191 | ctx.Add("{}=textureLodOffset({},{},{},{});", texel, texture, coords, lod_lc, | 204 | ctx.Add("{}=textureLodOffset({},{},{},{});", texel, texture, coords, lod_lc, |
| 192 | GetOffsetVec(ctx, offset)); | 205 | GetOffsetVec(ctx, offset)); |
| @@ -195,7 +208,6 @@ void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu | |||
| 195 | } | 208 | } |
| 196 | return; | 209 | return; |
| 197 | } | 210 | } |
| 198 | // TODO: Query sparseTexels extension support | ||
| 199 | if (!offset.IsEmpty()) { | 211 | if (!offset.IsEmpty()) { |
| 200 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", | 212 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", |
| 201 | *sparse_inst, texture, CastToIntVec(coords, info), lod_lc, | 213 | *sparse_inst, texture, CastToIntVec(coords, info), lod_lc, |
| @@ -315,7 +327,12 @@ void EmitImageGather(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 315 | const auto texture{Texture(ctx, info, index)}; | 327 | const auto texture{Texture(ctx, info, index)}; |
| 316 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 328 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 317 | const auto sparse_inst{PrepareSparse(inst)}; | 329 | const auto sparse_inst{PrepareSparse(inst)}; |
| 318 | if (!sparse_inst) { | 330 | const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; |
| 331 | if (sparse_inst && !supports_sparse) { | ||
| 332 | // LOG_WARNING(..., "Device does not support sparse texture queries. STUBBING"); | ||
| 333 | ctx.AddU1("{}=true;", *sparse_inst); | ||
| 334 | } | ||
| 335 | if (!sparse_inst || !supports_sparse) { | ||
| 319 | if (offset.IsEmpty()) { | 336 | if (offset.IsEmpty()) { |
| 320 | ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords, | 337 | ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords, |
| 321 | info.gather_component); | 338 | info.gather_component); |
| @@ -332,7 +349,6 @@ void EmitImageGather(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 332 | info.gather_component); | 349 | info.gather_component); |
| 333 | return; | 350 | return; |
| 334 | } | 351 | } |
| 335 | // TODO: Query sparseTexels extension support | ||
| 336 | if (offset.IsEmpty()) { | 352 | if (offset.IsEmpty()) { |
| 337 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureGatherARB({},{},{},int({})));", | 353 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureGatherARB({},{},{},int({})));", |
| 338 | *sparse_inst, texture, coords, texel, info.gather_component); | 354 | *sparse_inst, texture, coords, texel, info.gather_component); |
| @@ -358,7 +374,12 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde | |||
| 358 | const auto texture{Texture(ctx, info, index)}; | 374 | const auto texture{Texture(ctx, info, index)}; |
| 359 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 375 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 360 | const auto sparse_inst{PrepareSparse(inst)}; | 376 | const auto sparse_inst{PrepareSparse(inst)}; |
| 361 | if (!sparse_inst) { | 377 | const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; |
| 378 | if (sparse_inst && !supports_sparse) { | ||
| 379 | // LOG_WARNING(..., "Device does not support sparse texture queries. STUBBING"); | ||
| 380 | ctx.AddU1("{}=true;", *sparse_inst); | ||
| 381 | } | ||
| 382 | if (!sparse_inst || !supports_sparse) { | ||
| 362 | if (offset.IsEmpty()) { | 383 | if (offset.IsEmpty()) { |
| 363 | ctx.Add("{}=textureGather({},{},{});", texel, texture, coords, dref); | 384 | ctx.Add("{}=textureGather({},{},{});", texel, texture, coords, dref); |
| 364 | return; | 385 | return; |
| @@ -373,7 +394,6 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde | |||
| 373 | ctx.Add("{}=textureGatherOffsets({},{},{},{});", texel, texture, coords, dref, offsets); | 394 | ctx.Add("{}=textureGatherOffsets({},{},{},{});", texel, texture, coords, dref, offsets); |
| 374 | return; | 395 | return; |
| 375 | } | 396 | } |
| 376 | // TODO: Query sparseTexels extension support | ||
| 377 | if (offset.IsEmpty()) { | 397 | if (offset.IsEmpty()) { |
| 378 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureGatherARB({},{},{},{}));", *sparse_inst, | 398 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTextureGatherARB({},{},{},{}));", *sparse_inst, |
| 379 | texture, coords, dref, texel); | 399 | texture, coords, dref, texel); |
| @@ -404,7 +424,12 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 404 | const auto texture{Texture(ctx, info, index)}; | 424 | const auto texture{Texture(ctx, info, index)}; |
| 405 | const auto sparse_inst{PrepareSparse(inst)}; | 425 | const auto sparse_inst{PrepareSparse(inst)}; |
| 406 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 426 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 407 | if (!sparse_inst) { | 427 | const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; |
| 428 | if (sparse_inst && !supports_sparse) { | ||
| 429 | // LOG_WARNING(..., "Device does not support sparse texture queries. STUBBING"); | ||
| 430 | ctx.AddU1("{}=true;", *sparse_inst); | ||
| 431 | } | ||
| 432 | if (!sparse_inst || !supports_sparse) { | ||
| 408 | if (!offset.empty()) { | 433 | if (!offset.empty()) { |
| 409 | ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, | 434 | ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, |
| 410 | CoordsCastToInt(coords, info), lod, CoordsCastToInt(offset, info)); | 435 | CoordsCastToInt(coords, info), lod, CoordsCastToInt(offset, info)); |
| @@ -418,7 +443,6 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 418 | } | 443 | } |
| 419 | return; | 444 | return; |
| 420 | } | 445 | } |
| 421 | // TODO: Query sparseTexels extension support | ||
| 422 | if (!offset.empty()) { | 446 | if (!offset.empty()) { |
| 423 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", | 447 | ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", |
| 424 | *sparse_inst, texture, CastToIntVec(coords, info), lod, | 448 | *sparse_inst, texture, CastToIntVec(coords, info), lod, |
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 246995190..236c79a0a 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h | |||
| @@ -87,6 +87,8 @@ struct Profile { | |||
| 87 | bool support_gl_amd_gpu_shader_half_float{}; | 87 | bool support_gl_amd_gpu_shader_half_float{}; |
| 88 | bool support_gl_texture_shadow_lod{}; | 88 | bool support_gl_texture_shadow_lod{}; |
| 89 | bool support_gl_warp_intrinsics{}; | 89 | bool support_gl_warp_intrinsics{}; |
| 90 | bool support_gl_variable_aoffi{}; | ||
| 91 | bool support_gl_sparse_textures{}; | ||
| 90 | 92 | ||
| 91 | bool warp_size_potentially_larger_than_guest{}; | 93 | bool warp_size_potentially_larger_than_guest{}; |
| 92 | 94 | ||