From ae8c556c20bd64f215e3fd27d0e7e6158ddf7682 Mon Sep 17 00:00:00 2001 From: dcvz Date: Thu, 16 May 2024 00:19:55 +0200 Subject: [PATCH] Remove GS shaders --- CMakeLists.txt | 8 +---- src/render/rt64_raster_shader.cpp | 6 ++++ src/render/rt64_shader_library.cpp | 48 +++++++++++++++++++++++++++--- src/shaders/Im3DGSLines.hlsl | 38 ----------------------- src/shaders/Im3DGSPoints.hlsl | 29 ------------------ 5 files changed, 51 insertions(+), 78 deletions(-) delete mode 100644 src/shaders/Im3DGSLines.hlsl delete mode 100644 src/shaders/Im3DGSPoints.hlsl diff --git a/CMakeLists.txt b/CMakeLists.txt index 77bf6de..2faef5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ function(build_shader_msl_impl TARGETOBJ FILENAME TARGET_NAME OUTNAME) COMMAND ${DXC} ${DXC_SPV_OPTS} ${ARGN} ${FILENAME} /Fo ${OUTNAME}.spv DEPENDS ${FILENAME}) add_custom_command(OUTPUT ${OUTNAME}.metal - COMMAND pkgx spirv-cross ${OUTNAME}.spv --msl --output ${OUTNAME}.metal --msl-version 20000 --msl-argument-buffers + COMMAND pkgx spirv-cross ${OUTNAME}.spv --msl --output ${OUTNAME}.metal --msl-version 20000 --msl-argument-buffers --msl-force-native-arrays DEPENDS ${OUTNAME}.spv) add_custom_command(OUTPUT ${OUTNAME}.ir COMMAND xcrun -sdk macosx metal -o ${OUTNAME}.ir -c ${OUTNAME}.metal @@ -217,10 +217,6 @@ function(build_compute_shader TARGETOBJ SHADERNAME) build_shader(${TARGETOBJ} ${SHADERNAME} "${DXC_CS_OPTS}" ${ARGN}) endfunction() -function(build_geo_shader TARGETOBJ SHADERNAME) - build_shader(${TARGETOBJ} ${SHADERNAME} "${DXC_GS_OPTS}" ${ARGN}) -endfunction() - function(build_ray_shader TARGETOBJ SHADERNAME) build_shader(${TARGETOBJ} ${SHADERNAME} "${DXC_RT_OPTS}" ${ARGN}) endfunction() @@ -460,8 +456,6 @@ build_pixel_shader( rt64 "src/shaders/VideoInterfacePS.hlsl" "src/shaders/Video build_pixel_shader( rt64 "src/shaders/VideoInterfacePS.hlsl" "src/shaders/VideoInterfacePSPixel.hlsl" "-D PIXEL_ANTIALIASING") build_vertex_shader( rt64 "src/shaders/FullScreenVS.hlsl") build_vertex_shader( rt64 "src/shaders/Im3DVS.hlsl") -build_geo_shader( rt64 "src/shaders/Im3DGSPoints.hlsl") -build_geo_shader( rt64 "src/shaders/Im3DGSLines.hlsl") build_pixel_shader( rt64 "src/shaders/ComposePS.hlsl") build_pixel_shader( rt64 "src/shaders/DebugPS.hlsl") build_pixel_shader( rt64 "src/shaders/Im3DPS.hlsl") diff --git a/src/render/rt64_raster_shader.cpp b/src/render/rt64_raster_shader.cpp index 7f255e1..cd853a9 100644 --- a/src/render/rt64_raster_shader.cpp +++ b/src/render/rt64_raster_shader.cpp @@ -6,6 +6,7 @@ #include "xxHash/xxh3.h" +#ifndef __APPLE__ #include "shaders/RasterPSDynamic.hlsl.spirv.h" #include "shaders/RasterPSDynamicMS.hlsl.spirv.h" #include "shaders/RasterPSSpecConstant.hlsl.spirv.h" @@ -17,10 +18,15 @@ #include "shaders/RasterVSDynamic.hlsl.spirv.h" #include "shaders/RasterVSSpecConstant.hlsl.spirv.h" #include "shaders/RasterVSSpecConstantFlat.hlsl.spirv.h" +#endif #ifdef _WIN32 # include "shaders/RasterPSDynamic.hlsl.dxil.h" # include "shaders/RasterPSDynamicMS.hlsl.dxil.h" # include "shaders/RasterVSDynamic.hlsl.dxil.h" +#elif defined(__APPLE__) +# include "shaders/RasterPSDynamic.hlsl.metallib.h" +# include "shaders/RasterPSDynamicMS.hlsl.metallib.h" +# include "shaders/RasterVSDynamic.hlsl.metallib.h" #endif #include "shaders/RasterPS.hlsl.rw.h" #include "shaders/RasterVS.hlsl.rw.h" diff --git a/src/render/rt64_shader_library.cpp b/src/render/rt64_shader_library.cpp index bc31af1..d8cd7c3 100644 --- a/src/render/rt64_shader_library.cpp +++ b/src/render/rt64_shader_library.cpp @@ -7,6 +7,7 @@ #include "common/rt64_common.h" #include "shared/rt64_rsp_vertex_test_z.h" +#ifndef __APPLE__ #include "shaders/FbChangesClearCS.hlsl.spirv.h" #include "shaders/FbChangesDrawColorPS.hlsl.spirv.h" #include "shaders/FbChangesDrawDepthPS.hlsl.spirv.h" @@ -40,12 +41,11 @@ #include "shaders/VideoInterfacePSPixel.hlsl.spirv.h" #include "shaders/FullScreenVS.hlsl.spirv.h" #include "shaders/Im3DVS.hlsl.spirv.h" -#include "shaders/Im3DGSPoints.hlsl.spirv.h" -#include "shaders/Im3DGSLines.hlsl.spirv.h" #include "shaders/ComposePS.hlsl.spirv.h" #include "shaders/DebugPS.hlsl.spirv.h" #include "shaders/Im3DPS.hlsl.spirv.h" #include "shaders/PostProcessPS.hlsl.spirv.h" +#endif #ifdef _WIN32 # include "shaders/FbChangesClearCS.hlsl.dxil.h" @@ -81,12 +81,52 @@ # include "shaders/VideoInterfacePSPixel.hlsl.dxil.h" # include "shaders/FullScreenVS.hlsl.dxil.h" # include "shaders/Im3DVS.hlsl.dxil.h" -# include "shaders/Im3DGSPoints.hlsl.dxil.h" -# include "shaders/Im3DGSLines.hlsl.dxil.h" # include "shaders/ComposePS.hlsl.dxil.h" # include "shaders/DebugPS.hlsl.dxil.h" # include "shaders/Im3DPS.hlsl.dxil.h" # include "shaders/PostProcessPS.hlsl.dxil.h" +#elif defined(__APPLE__) +#include "shaders/FbChangesClearCS.hlsl.metallib.h" +#include "shaders/FbChangesDrawColorPS.hlsl.metallib.h" +#include "shaders/FbChangesDrawDepthPS.hlsl.metallib.h" +#include "shaders/FbReadAnyChangesCS.hlsl.metallib.h" +#include "shaders/FbReadAnyFullCS.hlsl.metallib.h" +#include "shaders/FbReinterpretCS.hlsl.metallib.h" +#include "shaders/FbWriteColorCS.hlsl.metallib.h" +#include "shaders/FbWriteDepthCS.hlsl.metallib.h" +#include "shaders/FbWriteDepthCSMS.hlsl.metallib.h" +#include "shaders/GaussianFilterRGB3x3CS.hlsl.metallib.h" +#include "shaders/BoxFilterCS.hlsl.metallib.h" +#include "shaders/BicubicScalingCS.hlsl.metallib.h" +#include "shaders/HistogramAverageCS.hlsl.metallib.h" +#include "shaders/HistogramClearCS.hlsl.metallib.h" +#include "shaders/HistogramSetCS.hlsl.metallib.h" +#include "shaders/IdleCS.hlsl.metallib.h" +#include "shaders/LuminanceHistogramCS.hlsl.metallib.h" +#include "shaders/RSPModifyCS.hlsl.metallib.h" +#include "shaders/RSPProcessCS.hlsl.metallib.h" +#include "shaders/RSPSmoothNormalCS.hlsl.metallib.h" +#include "shaders/RSPVertexTestZCS.hlsl.metallib.h" +#include "shaders/RSPVertexTestZCSMS.hlsl.metallib.h" +#include "shaders/RSPWorldCS.hlsl.metallib.h" +#include "shaders/RtCopyColorToDepthPS.hlsl.metallib.h" +#include "shaders/RtCopyColorToDepthPSMS.hlsl.metallib.h" +#include "shaders/RtCopyDepthToColorPS.hlsl.metallib.h" +#include "shaders/RtCopyDepthToColorPSMS.hlsl.metallib.h" +#include "shaders/TextureCopyPS.hlsl.metallib.h" +#include "shaders/TextureDecodeCS.hlsl.metallib.h" +#include "shaders/VideoInterfacePSRegular.hlsl.metallib.h" +#include "shaders/VideoInterfacePSPixel.hlsl.metallib.h" +#include "shaders/FullScreenVS.hlsl.metallib.h" +#include "shaders/Im3DVS.hlsl.metallib.h" +#include "shaders/Im3DGSPoints.hlsl.metallib.h" +#include "shaders/Im3DGSLines.hlsl.metallib.h" +#include "shaders/ComposePS.hlsl.metallib.h" +#include "shaders/DebugPS.hlsl.metallib.h" +#include "shaders/Im3DPS.hlsl.metallib.h" +#include "shaders/PostProcessPS.hlsl.metallib.h" +#else + #endif #include "shared/rt64_fb_common.h" diff --git a/src/shaders/Im3DGSLines.hlsl b/src/shaders/Im3DGSLines.hlsl deleted file mode 100644 index c0ae8d2..0000000 --- a/src/shaders/Im3DGSLines.hlsl +++ /dev/null @@ -1,38 +0,0 @@ -// -// Im3d Dx12 -// - -#include "Im3DCommon.hlsli" -#include "FbRendererRT.hlsli" - -[maxvertexcount(4)] -void GSMain(line VS_OUTPUT _in[2], inout TriangleStream out_) { - float2 pos0 = _in[0].m_position.xy / _in[0].m_position.w; - float2 pos1 = _in[1].m_position.xy / _in[1].m_position.w; - - float2 dir = pos0 - pos1; - dir = normalize(float2(dir.x, dir.y * RtParams.resolution.w / RtParams.resolution.z)); // correct for aspect ratio - float2 tng0 = float2(-dir.y, dir.x); - float2 tng1 = tng0 * _in[1].m_size / RtParams.resolution.zw; - tng0 = tng0 * _in[0].m_size / RtParams.resolution.zw; - - VS_OUTPUT ret; - - // line start - ret.m_size = _in[0].m_size; - ret.m_color = _in[0].m_color; - ret.m_position = float4((pos0 - tng0) * _in[0].m_position.w, _in[0].m_position.zw); - ret.m_worldPosition = _in[0].m_worldPosition; - out_.Append(ret); - ret.m_position = float4((pos0 + tng0) * _in[0].m_position.w, _in[0].m_position.zw); - out_.Append(ret); - - // line end - ret.m_size = _in[1].m_size; - ret.m_color = _in[1].m_color; - ret.m_position = float4((pos1 - tng1) * _in[1].m_position.w, _in[1].m_position.zw); - ret.m_worldPosition = _in[1].m_worldPosition; - out_.Append(ret); - ret.m_position = float4((pos1 + tng1) * _in[1].m_position.w, _in[1].m_position.zw); - out_.Append(ret); -} \ No newline at end of file diff --git a/src/shaders/Im3DGSPoints.hlsl b/src/shaders/Im3DGSPoints.hlsl deleted file mode 100644 index cc240a7..0000000 --- a/src/shaders/Im3DGSPoints.hlsl +++ /dev/null @@ -1,29 +0,0 @@ -// -// Im3d Dx12 -// - -#include "Im3DCommon.hlsli" -#include "FbRendererRT.hlsli" - -// expand point -> triangle strip (quad) -[maxvertexcount(4)] -void GSMain(point VS_OUTPUT _in[1], inout TriangleStream out_) { - VS_OUTPUT ret; - - float2 scale = 1.0 / RtParams.resolution.zw * _in[0].m_size; - ret.m_size = _in[0].m_size; - ret.m_color = _in[0].m_color; - ret.m_worldPosition = _in[0].m_worldPosition; - - ret.m_position = float4(_in[0].m_position.xy + float2(-1.0, -1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); - out_.Append(ret); - - ret.m_position = float4(_in[0].m_position.xy + float2(1.0, -1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); - out_.Append(ret); - - ret.m_position = float4(_in[0].m_position.xy + float2(-1.0, 1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); - out_.Append(ret); - - ret.m_position = float4(_in[0].m_position.xy + float2(1.0, 1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); - out_.Append(ret); -} \ No newline at end of file