forked from blender/blender
me-main #1
@ -77,6 +77,11 @@ template<> uint convert_type<uint>(float val)
|
|||||||
return uint(val * float(0xFFFFFFFFu));
|
return uint(val * float(0xFFFFFFFFu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename D, typename S> uint pack_depth_stencil(D depth, S stencil)
|
||||||
|
{
|
||||||
|
return (((uint(depth)) << 8) & (~(0xFFu - 1))) | (uint(stencil) & (0xFFu - 1));
|
||||||
|
}
|
||||||
|
|
||||||
struct TextureReadParams {
|
struct TextureReadParams {
|
||||||
int mip_index;
|
int mip_index;
|
||||||
int extent[3];
|
int extent[3];
|
||||||
@ -118,8 +123,14 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||||||
|
|
||||||
/* Read data */
|
/* Read data */
|
||||||
# if IS_DEPTH_FORMAT == 1
|
# if IS_DEPTH_FORMAT == 1
|
||||||
output_data[index] = denormalize<OUTPUT_DATA_TYPE>(
|
OUTPUT_DATA_TYPE value = denormalize<OUTPUT_DATA_TYPE>(
|
||||||
read_tex.sample(pixelSampler, float2(params.offset[0], params.offset[1]) + float2(xx, yy)));
|
read_tex.sample(pixelSampler, float2(params.offset[0], params.offset[1]) + float2(xx, yy)));
|
||||||
|
# if IS_DEPTHSTENCIL_24_8 == 1
|
||||||
|
/* Shift depth value into 24 bit region and mask out 8 bit stencil.
|
||||||
|
* NOTE: Stencil currently not read as no use cases exist for this. */
|
||||||
|
value = pack_depth_stencil(value, 0);
|
||||||
|
# endif
|
||||||
|
output_data[index] = value;
|
||||||
# else
|
# else
|
||||||
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy));
|
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy));
|
||||||
# endif
|
# endif
|
||||||
@ -156,10 +167,16 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||||||
|
|
||||||
/* Read data */
|
/* Read data */
|
||||||
# if IS_DEPTH_FORMAT == 1
|
# if IS_DEPTH_FORMAT == 1
|
||||||
output_data[index] = denormalize<OUTPUT_DATA_TYPE>(
|
OUTPUT_DATA_TYPE value = denormalize<OUTPUT_DATA_TYPE>(
|
||||||
read_tex.sample(pixelSampler,
|
read_tex.sample(pixelSampler,
|
||||||
float2(params.offset[0], params.offset[1]) + float2(xx, yy),
|
float2(params.offset[0], params.offset[1]) + float2(xx, yy),
|
||||||
uint(params.offset[2] + layer)));
|
uint(params.offset[2] + layer)));
|
||||||
|
# if IS_DEPTHSTENCIL_24_8 == 1
|
||||||
|
/* Shift depth value into 24 bit region and mask out 8 bit stencil.
|
||||||
|
* NOTE: Stencil currently not read as no use cases exist for this. */
|
||||||
|
value = pack_depth_stencil(value, 0);
|
||||||
|
# endif
|
||||||
|
output_data[index] = value;
|
||||||
# else
|
# else
|
||||||
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy),
|
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy),
|
||||||
uint(params.offset[2] + layer));
|
uint(params.offset[2] + layer));
|
||||||
|
@ -647,7 +647,9 @@ id<MTLComputePipelineState> gpu::MTLTexture::mtl_texture_read_impl(
|
|||||||
@"IS_DEPTH_FORMAT" :
|
@"IS_DEPTH_FORMAT" :
|
||||||
[NSNumber numberWithInt:((specialization_params.depth_format_mode > 0) ? 1 : 0)],
|
[NSNumber numberWithInt:((specialization_params.depth_format_mode > 0) ? 1 : 0)],
|
||||||
@"DEPTH_SCALE_FACTOR" : [NSNumber numberWithLongLong:depth_scale_factor],
|
@"DEPTH_SCALE_FACTOR" : [NSNumber numberWithLongLong:depth_scale_factor],
|
||||||
@"TEX_TYPE" : [NSNumber numberWithInt:((int)(texture_type))]
|
@"TEX_TYPE" : [NSNumber numberWithInt:((int)(texture_type))],
|
||||||
|
@"IS_DEPTHSTENCIL_24_8" :
|
||||||
|
[NSNumber numberWithInt:(specialization_params.depth_format_mode == 2) ? 1 : 0]
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Prepare shader library for conversion routine. */
|
/* Prepare shader library for conversion routine. */
|
||||||
|
Loading…
Reference in New Issue
Block a user