Use the _xe suffix instead of the xesl_ prefix for quicker visual recognition of identifiers, also switch to snake_case for consistency. Also add the f suffix to float32 literals because the Metal Shading Language is based on C++.
66 lines
2.4 KiB
Plaintext
66 lines
2.4 KiB
Plaintext
/**
|
|
******************************************************************************
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
******************************************************************************
|
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
******************************************************************************
|
|
*/
|
|
|
|
#include "endian.xesli"
|
|
#include "pixel_formats.xesli"
|
|
#define XE_RESOLVE_COPY_EDRAM_IS_UINT_VECTOR_BUFFER
|
|
#include "resolve.xesli"
|
|
|
|
array_buffer_wo_declare_xe(uint2_xe, xe_resolve_dest, set=1, binding=0, u0,
|
|
space0)
|
|
#define LOCAL_SIZE_X_XE 8
|
|
#define LOCAL_SIZE_Y_XE 8
|
|
#define LOCAL_SIZE_Z_XE 1
|
|
entry_bindings_begin_compute_xe
|
|
XE_RESOLVE_PUSH_CONST_BINDING
|
|
entry_binding_next_xe
|
|
array_buffer_wo_binding_xe(uint2_xe, xe_resolve_dest, buffer(1))
|
|
entry_binding_next_xe
|
|
XE_RESOLVE_COPY_EDRAM_BINDING
|
|
entry_bindings_end_inputs_begin_compute_xe
|
|
entry_in_global_thread_id_xe
|
|
entry_inputs_end_code_begin_compute_xe
|
|
{
|
|
// 1 thread = 8 host pixels.
|
|
XeResolveInfo resolve_info = XeResolveGetInfo(pass_push_consts_xe);
|
|
// Group height can't cross resolve granularity, Y overflow check not needed.
|
|
dont_flatten_xe
|
|
if (in_global_thread_id_xe.x >= resolve_info.width_div_8_scaled) {
|
|
return;
|
|
}
|
|
uint2_xe pixel_index = in_global_thread_id_xe.xy << uint2_xe(3u, 0u);
|
|
float4_xe pixels_0123, pixels_4567;
|
|
XeResolveLoad8RedColors(
|
|
pass_uint_vector_buffer_xe(xe_resolve_edram)
|
|
pass_next_after_uint_vector_buffer_xe
|
|
resolve_info,
|
|
XeResolveColorCopySourcePixelAddressIntsYHalfPixelOffsetFilling(
|
|
resolve_info, pixel_index),
|
|
pixels_0123, pixels_4567);
|
|
dont_flatten_xe
|
|
if (pixel_index.x == 0u &&
|
|
resolve_info.half_pixel_offset_fill_source.x != 0u) {
|
|
if (resolve_info.half_pixel_offset_fill_source.x >= 2u) {
|
|
if (resolve_info.half_pixel_offset_fill_source.x >= 3u) {
|
|
pixels_0123.z = pixels_0123.w;
|
|
}
|
|
pixels_0123.y = pixels_0123.z;
|
|
}
|
|
pixels_0123.x = pixels_0123.y;
|
|
}
|
|
// Convert to R8.
|
|
// TODO(Triang3l): Investigate formats 8_A and 8_B.
|
|
array_buffer_store_xe(
|
|
xe_resolve_dest,
|
|
XeResolveDestPixelAddress(resolve_info, pixel_index, 0u) >> 3u,
|
|
uint2_xe(XePackR8G8B8A8UNorm(pixels_0123),
|
|
XePackR8G8B8A8UNorm(pixels_4567)));
|
|
}
|
|
entry_code_end_compute_xe
|