Fix image load/store on cube arrays in MSL.
This commit is contained in:
parent
8bac5c09f3
commit
04b149feb0
@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
kernel void main0(texturecube_array<float> uImageIn [[texture(0)]], texturecube_array<float, access::write> uImageOut [[texture(1)]])
|
||||
{
|
||||
uImageOut.write(uImageIn.read(uint2(int3(9, 7, 11).xy), uint(int3(9, 7, 11).z) % 6u, uint(int3(9, 7, 11).z) / 6u), uint2(int3(9, 7, 11).xy), uint(int3(9, 7, 11).z) % 6u, uint(int3(9, 7, 11).z) / 6u);
|
||||
}
|
||||
|
12
reference/shaders-msl/comp/image-cube-array-load-store.comp
Normal file
12
reference/shaders-msl/comp/image-cube-array-load-store.comp
Normal file
@ -0,0 +1,12 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
kernel void main0(texturecube_array<float> uImageIn [[texture(0)]], texturecube_array<float, access::write> uImageOut [[texture(1)]])
|
||||
{
|
||||
int3 coord = int3(9, 7, 11);
|
||||
float4 indata = uImageIn.read(uint2(coord.xy), uint(coord.z) % 6u, uint(coord.z) / 6u);
|
||||
uImageOut.write(indata, uint2(coord.xy), uint(coord.z) % 6u, uint(coord.z) / 6u);
|
||||
}
|
||||
|
13
shaders-msl/comp/image-cube-array-load-store.comp
Normal file
13
shaders-msl/comp/image-cube-array-load-store.comp
Normal file
@ -0,0 +1,13 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
layout(r32f, binding = 0) uniform readonly imageCubeArray uImageIn;
|
||||
layout(r32f, binding = 1) uniform writeonly imageCubeArray uImageOut;
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec3 coord = ivec3(9, 7, 11);
|
||||
vec4 indata = imageLoad(uImageIn, coord);
|
||||
imageStore(uImageOut, coord, indata);
|
||||
}
|
||||
|
@ -2613,11 +2613,23 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
||||
|
||||
// If fetch from cube, add face explicitly
|
||||
if (is_cube_fetch)
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + ".z", coord_is_fp) + ")";
|
||||
{
|
||||
// Special case for cube arrays, face and layer are packed in one dimension.
|
||||
if (imgtype.image.arrayed)
|
||||
farg_str += ", uint(" + join(coord_expr, ".z) % 6u");
|
||||
else
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + ".z", coord_is_fp) + ")";
|
||||
}
|
||||
|
||||
// If array, use alt coord
|
||||
if (imgtype.image.arrayed)
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + alt_coord, coord_is_fp) + ")";
|
||||
{
|
||||
// Special case for cube arrays, face and layer are packed in one dimension.
|
||||
if (imgtype.image.dim == DimCube && is_fetch)
|
||||
farg_str += ", uint(" + join(coord_expr, ".z) / 6u");
|
||||
else
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + alt_coord, coord_is_fp) + ")";
|
||||
}
|
||||
|
||||
// Depth compare reference value
|
||||
if (dref)
|
||||
|
Loading…
Reference in New Issue
Block a user