diff options
| author | 2021-04-09 01:45:39 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:26 -0400 | |
| commit | 7cb2ab358517d95ebcd35c94c72b9e91762906c3 (patch) | |
| tree | 3f75959e255026665a4dde406cb8c4cc34fb45a0 /src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |
| parent | shader: Fix Windows build issues (diff) | |
| download | yuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.tar.gz yuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.tar.xz yuzu-7cb2ab358517d95ebcd35c94c72b9e91762906c3.zip | |
shader: Implement SULD and SUST
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 6a89c0f79..dd261fd47 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -144,6 +144,18 @@ Id TextureImage(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo in | |||
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | Id Image(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo info) { | ||
| 148 | if (!index.IsImmediate()) { | ||
| 149 | throw NotImplementedException("Indirect image indexing"); | ||
| 150 | } | ||
| 151 | if (info.type == TextureType::Buffer) { | ||
| 152 | throw NotImplementedException("Image buffer"); | ||
| 153 | } else { | ||
| 154 | const ImageDefinition def{ctx.images.at(index.U32())}; | ||
| 155 | return ctx.OpLoad(def.image_type, def.id); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 147 | Id Decorate(EmitContext& ctx, IR::Inst* inst, Id sample) { | 159 | Id Decorate(EmitContext& ctx, IR::Inst* inst, Id sample) { |
| 148 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 160 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 149 | if (info.relaxed_precision != 0) { | 161 | if (info.relaxed_precision != 0) { |
| @@ -209,6 +221,14 @@ Id EmitBindlessImageGradient(EmitContext&) { | |||
| 209 | throw LogicError("Unreachable instruction"); | 221 | throw LogicError("Unreachable instruction"); |
| 210 | } | 222 | } |
| 211 | 223 | ||
| 224 | Id EmitBindlessImageRead(EmitContext&) { | ||
| 225 | throw LogicError("Unreachable instruction"); | ||
| 226 | } | ||
| 227 | |||
| 228 | Id EmitBindlessImageWrite(EmitContext&) { | ||
| 229 | throw LogicError("Unreachable instruction"); | ||
| 230 | } | ||
| 231 | |||
| 212 | Id EmitBoundImageSampleImplicitLod(EmitContext&) { | 232 | Id EmitBoundImageSampleImplicitLod(EmitContext&) { |
| 213 | throw LogicError("Unreachable instruction"); | 233 | throw LogicError("Unreachable instruction"); |
| 214 | } | 234 | } |
| @@ -249,6 +269,14 @@ Id EmitBoundImageGradient(EmitContext&) { | |||
| 249 | throw LogicError("Unreachable instruction"); | 269 | throw LogicError("Unreachable instruction"); |
| 250 | } | 270 | } |
| 251 | 271 | ||
| 272 | Id EmitBoundImageRead(EmitContext&) { | ||
| 273 | throw LogicError("Unreachable instruction"); | ||
| 274 | } | ||
| 275 | |||
| 276 | Id EmitBoundImageWrite(EmitContext&) { | ||
| 277 | throw LogicError("Unreachable instruction"); | ||
| 278 | } | ||
| 279 | |||
| 252 | Id EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 280 | Id EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 253 | Id bias_lc, Id offset) { | 281 | Id bias_lc, Id offset) { |
| 254 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 282 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| @@ -322,23 +350,16 @@ Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& i | |||
| 322 | const auto mips{[&] { return ctx.OpImageQueryLevels(ctx.U32[1], image); }}; | 350 | const auto mips{[&] { return ctx.OpImageQueryLevels(ctx.U32[1], image); }}; |
| 323 | switch (info.type) { | 351 | switch (info.type) { |
| 324 | case TextureType::Color1D: | 352 | case TextureType::Color1D: |
| 325 | case TextureType::Shadow1D: | ||
| 326 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod), | 353 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod), |
| 327 | zero, zero, mips()); | 354 | zero, zero, mips()); |
| 328 | case TextureType::ColorArray1D: | 355 | case TextureType::ColorArray1D: |
| 329 | case TextureType::Color2D: | 356 | case TextureType::Color2D: |
| 330 | case TextureType::ColorCube: | 357 | case TextureType::ColorCube: |
| 331 | case TextureType::ShadowArray1D: | ||
| 332 | case TextureType::Shadow2D: | ||
| 333 | case TextureType::ShadowCube: | ||
| 334 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[2], image, lod), | 358 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[2], image, lod), |
| 335 | zero, mips()); | 359 | zero, mips()); |
| 336 | case TextureType::ColorArray2D: | 360 | case TextureType::ColorArray2D: |
| 337 | case TextureType::Color3D: | 361 | case TextureType::Color3D: |
| 338 | case TextureType::ColorArrayCube: | 362 | case TextureType::ColorArrayCube: |
| 339 | case TextureType::ShadowArray2D: | ||
| 340 | case TextureType::Shadow3D: | ||
| 341 | case TextureType::ShadowArrayCube: | ||
| 342 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[3], image, lod), | 363 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[3], image, lod), |
| 343 | mips()); | 364 | mips()); |
| 344 | case TextureType::Buffer: | 365 | case TextureType::Buffer: |
| @@ -365,4 +386,15 @@ Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, I | |||
| 365 | coords, operands.Mask(), operands.Span()); | 386 | coords, operands.Mask(), operands.Span()); |
| 366 | } | 387 | } |
| 367 | 388 | ||
| 389 | Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords) { | ||
| 390 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | ||
| 391 | return Emit(&EmitContext::OpImageSparseRead, &EmitContext::OpImageRead, ctx, inst, ctx.U32[4], | ||
| 392 | Image(ctx, index, info), coords, std::nullopt, std::span<const Id>{}); | ||
| 393 | } | ||
| 394 | |||
| 395 | void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color) { | ||
| 396 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | ||
| 397 | ctx.OpImageWrite(Image(ctx, index, info), coords, color); | ||
| 398 | } | ||
| 399 | |||
| 368 | } // namespace Shader::Backend::SPIRV | 400 | } // namespace Shader::Backend::SPIRV |