summaryrefslogtreecommitdiff
path: root/mm/assets/custom/shaders/directx/default.shader.hlsl
diff options
context:
space:
mode:
Diffstat (limited to 'mm/assets/custom/shaders/directx/default.shader.hlsl')
-rw-r--r--mm/assets/custom/shaders/directx/default.shader.hlsl34
1 files changed, 28 insertions, 6 deletions
diff --git a/mm/assets/custom/shaders/directx/default.shader.hlsl b/mm/assets/custom/shaders/directx/default.shader.hlsl
index 980becb8c..3025a1121 100644
--- a/mm/assets/custom/shaders/directx/default.shader.hlsl
+++ b/mm/assets/custom/shaders/directx/default.shader.hlsl
@@ -77,7 +77,7 @@ float random(in float3 value) {
// Original author: ArthurCarvalho
// Based on GLSL implementation by twinaphex, mupen64plus-libretro project.
-@if(o_three_point_filtering && o_textures[0] || o_textures[1])
+@if(o_three_point_filtering && (o_textures[0] || o_textures[1]))
cbuffer PerDrawCB : register(b1) {
struct {
uint width;
@@ -98,6 +98,13 @@ float4 tex2D3PointFilter(in Texture2D tex, in SamplerState tSampler, in float2 t
}
@end
+@if(o_prim_depth)
+cbuffer PerPrimDepthCB : register(b2) {
+ float prim_depth;
+ float3 _pad; // pad to 16-byte cbuffer alignment
+}
+@end
+
PSInput VSMain(
float4 position : POSITION
@for(i in 0..2)
@@ -180,7 +187,14 @@ PSInput VSMain(
#define MOD(x, y) ((x) - (y) * floor((x)/(y)))
#define WRAP(x, low, high) MOD((x)-(low), (high)-(low)) + (low)
-float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET {
+struct PSOutput {
+ float4 color : SV_TARGET;
+ @if(o_prim_depth)
+ float depth : SV_Depth;
+ @end
+};
+
+PSOutput PSMain(PSInput input, float4 screenSpace : SV_Position) {
@for(i in 0..2)
@if(o_textures[i])
float2 tc@{i} = input.uv@{i};
@@ -317,16 +331,24 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET {
@if(o_invisible)
texel.a = 0.0;
@end
+ @end
+
+ PSOutput output;
+ @if(o_alpha)
@if(srgb_mode)
- return fromLinear(texel);
+ output.color = fromLinear(texel);
@else
- return texel;
+ output.color = texel;
@end
@else
@if(srgb_mode)
- return fromLinear(float4(texel, 1.0));
+ output.color = fromLinear(float4(texel, 1.0));
@else
- return float4(texel, 1.0);
+ output.color = float4(texel, 1.0);
@end
@end
+ @if(o_prim_depth)
+ output.depth = prim_depth;
+ @end
+ return output;
}