diff --git a/src/xenia/gpu/d3d12/d3d12_graphics_system.cc b/src/xenia/gpu/d3d12/d3d12_graphics_system.cc index b8438a6fe..6422973ee 100644 --- a/src/xenia/gpu/d3d12/d3d12_graphics_system.cc +++ b/src/xenia/gpu/d3d12/d3d12_graphics_system.cc @@ -142,6 +142,7 @@ X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor, stretch_pipeline_desc.VS.BytecodeLength = sizeof(fullscreen_vs); stretch_pipeline_desc.PS.pShaderBytecode = stretch_ps; stretch_pipeline_desc.PS.BytecodeLength = sizeof(stretch_ps); + // The shader will set alpha to 1, don't use output-merger to preserve it. stretch_pipeline_desc.BlendState.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; stretch_pipeline_desc.SampleMask = UINT_MAX; diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.cso b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.cso index 6a1fe6724..229d21858 100644 Binary files a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.cso and b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.cso differ diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.h b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.h index c41cf6287..e6fd53b4f 100644 --- a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.h +++ b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.h @@ -1,11 +1,11 @@ // generated from `xb buildhlsl` // source: stretch_gamma.ps.hlsl const uint8_t stretch_gamma_ps[] = { - 0x44, 0x58, 0x42, 0x43, 0x8D, 0x1B, 0xAE, 0x52, 0x96, 0x87, 0x7B, 0x8F, - 0xCB, 0xD3, 0xBC, 0x4B, 0xCF, 0xAF, 0x66, 0xA9, 0x01, 0x00, 0x00, 0x00, - 0x10, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x44, 0x58, 0x42, 0x43, 0x46, 0xCD, 0x15, 0xA8, 0x4D, 0x5B, 0xFD, 0x07, + 0x4C, 0x62, 0xA7, 0xD0, 0x61, 0x89, 0x85, 0xA6, 0x01, 0x00, 0x00, 0x00, + 0x24, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x48, 0x02, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, - 0x74, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xD8, 0x01, 0x00, 0x00, + 0x88, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xD8, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x05, 0xFF, 0xFF, 0x00, 0x05, 0x00, 0x00, 0xB0, 0x01, 0x00, 0x00, 0x13, 0x13, 0x44, 0x25, 0x3C, 0x00, 0x00, 0x00, @@ -16,7 +16,7 @@ const uint8_t stretch_gamma_ps[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, @@ -54,8 +54,8 @@ const uint8_t stretch_gamma_ps[] = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xAB, 0xAB, - 0x53, 0x48, 0x45, 0x58, 0xF0, 0x01, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x7C, 0x00, 0x00, 0x00, 0x6A, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x07, + 0x53, 0x48, 0x45, 0x58, 0x04, 0x02, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x6A, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x07, 0x46, 0x8E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0x00, 0x00, 0x06, 0x46, 0x6E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -67,20 +67,20 @@ const uint8_t stretch_gamma_ps[] = { 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0D, 0xF2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0D, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, - 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x80, 0x30, 0x80, + 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x80, 0x30, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, - 0x38, 0x00, 0x00, 0x09, 0x22, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x32, 0x00, 0x00, 0x09, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF6, 0x0F, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0D, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7E, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, @@ -94,19 +94,21 @@ const uint8_t stretch_gamma_ps[] = { 0x00, 0x00, 0x00, 0x00, 0x46, 0x7E, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x05, 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x46, 0x0E, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x01, - 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3F, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, + 0x94, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.txt b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.txt index c4addc470..2a06727e9 100644 --- a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.txt +++ b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_gamma_ps.txt @@ -17,7 +17,7 @@ // Name Type Format Dim ID HLSL Bind Count // ------------------------------ ---------- ------- ----------- ------- -------------- ------ // xe_sampler_linear_clamp sampler NA NA S0 s0 1 -// xe_texture texture float4 2d T0 t0 1 +// xe_texture texture float3 2d T0 t0 1 // xe_gamma_ramp texture float3 1d T1 t1 1 // XeStretchGammaRootConstants cbuffer NA NA CB0 cb0 1 // @@ -45,13 +45,14 @@ dcl_resource_texture1d (float,float,float,float) T1[1:1], space=0 dcl_input_ps linear v0.xy dcl_output o0.xyzw dcl_temps 2 -sample_l r0.xyzw, v0.xyxx, T0[0].xyzw, S0[0], l(0.000000) -add r1.x, -CB0[0][0].x, l(1.000000) -mul r1.y, CB0[0][0].x, l(0.500000) -mad r0.xyz, r0.xyzx, r1.xxxx, r1.yyyy +sample_l r0.xyz, v0.xyxx, T0[0].xyzw, S0[0], l(0.000000) +add r0.w, -CB0[0][0].x, l(1.000000) +mul r1.x, CB0[0][0].x, l(0.500000) +mad r0.xyz, r0.xyzx, r0.wwww, r1.xxxx sample_l r0.x, r0.x, T1[1].xyzw, S0[0], l(0.000000) sample_l r0.y, r0.y, T1[1].xyzw, S0[0], l(0.000000) sample_l r0.z, r0.z, T1[1].xyzw, S0[0], l(0.000000) -mov o0.xyzw, r0.xyzw +mov o0.xyz, r0.xyzx +mov o0.w, l(1.000000) ret -// Approximately 9 instruction slots used +// Approximately 10 instruction slots used diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.cso b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.cso index 1843dd639..c5a49abfd 100644 Binary files a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.cso and b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.cso differ diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.h b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.h index 5aa4fdb1e..7f850d127 100644 --- a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.h +++ b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.h @@ -1,11 +1,11 @@ // generated from `xb buildhlsl` // source: stretch.ps.hlsl const uint8_t stretch_ps[] = { - 0x44, 0x58, 0x42, 0x43, 0x84, 0x8B, 0x62, 0x99, 0x4D, 0x9D, 0x1A, 0x13, - 0x49, 0x13, 0xF7, 0x6B, 0x9F, 0x69, 0x25, 0x8A, 0x01, 0x00, 0x00, 0x00, - 0xB0, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x44, 0x58, 0x42, 0x43, 0x0B, 0x39, 0x5E, 0x9C, 0x0F, 0x3E, 0xAC, 0xF6, + 0x9E, 0xB3, 0x11, 0xC0, 0x9B, 0x25, 0x2E, 0x6E, 0x01, 0x00, 0x00, 0x00, + 0xE0, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x48, 0x01, 0x00, 0x00, 0x7C, 0x01, 0x00, 0x00, - 0x14, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xD8, 0x00, 0x00, 0x00, + 0x44, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x05, 0xFF, 0xFF, 0x00, 0x05, 0x00, 0x00, 0xAF, 0x00, 0x00, 0x00, 0x13, 0x13, 0x44, 0x25, 0x3C, 0x00, 0x00, 0x00, @@ -16,7 +16,7 @@ const uint8_t stretch_ps[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x65, 0x5F, 0x73, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x72, 0x5F, 0x6C, 0x69, 0x6E, 0x65, 0x61, 0x72, 0x5F, 0x63, 0x6C, 0x61, 0x6D, 0x70, 0x00, 0x78, 0x65, 0x5F, 0x74, @@ -33,26 +33,30 @@ const uint8_t stretch_ps[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xAB, 0xAB, 0x53, 0x48, 0x45, 0x58, - 0x90, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0xC0, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x6A, 0x08, 0x00, 0x01, 0x5A, 0x00, 0x00, 0x06, 0x46, 0x6E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x07, 0x46, 0x7E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, - 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0D, - 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x46, 0x7E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, + 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0D, 0x72, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x7E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.txt b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.txt index ff7c711a5..8495d8f55 100644 --- a/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.txt +++ b/src/xenia/gpu/shaders/bytecode/d3d12_5_1/stretch_ps.txt @@ -7,7 +7,7 @@ // Name Type Format Dim ID HLSL Bind Count // ------------------------------ ---------- ------- ----------- ------- -------------- ------ // xe_sampler_linear_clamp sampler NA NA S0 s0 1 -// xe_texture texture float4 2d T0 t0 1 +// xe_texture texture float3 2d T0 t0 1 // // // @@ -30,6 +30,9 @@ dcl_sampler S0[0:0], mode_default, space=0 dcl_resource_texture2d (float,float,float,float) T0[0:0], space=0 dcl_input_ps linear v0.xy dcl_output o0.xyzw -sample_l o0.xyzw, v0.xyxx, T0[0].xyzw, S0[0], l(0.000000) +dcl_temps 1 +sample_l r0.xyz, v0.xyxx, T0[0].xyzw, S0[0], l(0.000000) +mov o0.xyz, r0.xyzx +mov o0.w, l(1.000000) ret -// Approximately 2 instruction slots used +// Approximately 4 instruction slots used diff --git a/src/xenia/gpu/shaders/stretch.ps.hlsl b/src/xenia/gpu/shaders/stretch.ps.hlsl index 681552587..c7a568434 100644 --- a/src/xenia/gpu/shaders/stretch.ps.hlsl +++ b/src/xenia/gpu/shaders/stretch.ps.hlsl @@ -1,6 +1,8 @@ -Texture2D xe_texture : register(t0); +Texture2D xe_texture : register(t0); SamplerState xe_sampler_linear_clamp : register(s0); float4 main(float2 xe_texcoord : TEXCOORD) : SV_Target { - return xe_texture.SampleLevel(xe_sampler_linear_clamp, xe_texcoord, 0.0f); + // Force alpha to 1 to make sure the surface won't be translucent. + return float4( + xe_texture.SampleLevel(xe_sampler_linear_clamp, xe_texcoord, 0.0f), 1.0f); } diff --git a/src/xenia/gpu/shaders/stretch_gamma.ps.hlsl b/src/xenia/gpu/shaders/stretch_gamma.ps.hlsl index cfa545aa1..a13e333a8 100644 --- a/src/xenia/gpu/shaders/stretch_gamma.ps.hlsl +++ b/src/xenia/gpu/shaders/stretch_gamma.ps.hlsl @@ -1,4 +1,4 @@ -Texture2D xe_texture : register(t0); +Texture2D xe_texture : register(t0); Texture1D xe_gamma_ramp : register(t1); SamplerState xe_sampler_linear_clamp : register(s0); cbuffer XeStretchGammaRootConstants : register(b0) { @@ -6,14 +6,15 @@ cbuffer XeStretchGammaRootConstants : register(b0) { }; float4 main(float2 xe_texcoord : TEXCOORD) : SV_Target { - float4 color = + float3 color = xe_texture.SampleLevel(xe_sampler_linear_clamp, xe_texcoord, 0.0f); // The center of the first texel of the LUT contains the value for 0, and the // center of the last texel contains the value for 1. - color.rgb = color.rgb * (1.0f - xe_gamma_ramp_inv_size) + - (0.5 * xe_gamma_ramp_inv_size); + color = + color * (1.0f - xe_gamma_ramp_inv_size) + (0.5 * xe_gamma_ramp_inv_size); color.r = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.r, 0.0f).r; color.g = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.g, 0.0f).g; color.b = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.b, 0.0f).b; - return color; + // Force alpha to 1 to make sure the surface won't be translucent. + return float4(color, 1.0f); } diff --git a/src/xenia/ui/d3d12/d3d12_immediate_drawer.cc b/src/xenia/ui/d3d12/d3d12_immediate_drawer.cc index 6cc1e4d56..5bd8afa53 100644 --- a/src/xenia/ui/d3d12/d3d12_immediate_drawer.cc +++ b/src/xenia/ui/d3d12/d3d12_immediate_drawer.cc @@ -486,6 +486,10 @@ void D3D12ImmediateDrawer::Begin(int render_target_width, viewport.MinDepth = 0.0f; viewport.MaxDepth = 1.0f; current_command_list_->RSSetViewports(1, &viewport); + current_scissor_.left = 0; + current_scissor_.top = 0; + current_scissor_.right = 0; + current_scissor_.bottom = 0; current_command_list_->SetGraphicsRootSignature(root_signature_); float viewport_inv_size[2]; @@ -553,6 +557,32 @@ void D3D12ImmediateDrawer::Draw(const ImmediateDraw& draw) { auto& provider = context_.GetD3D12Provider(); auto device = provider.GetDevice(); + // Set the scissor rectangle if enabled. + D3D12_RECT scissor; + if (draw.scissor) { + scissor.left = draw.scissor_rect[0]; + scissor.top = current_render_target_height_ - + (draw.scissor_rect[1] + draw.scissor_rect[3]); + scissor.right = scissor.left + draw.scissor_rect[2]; + scissor.bottom = scissor.top + draw.scissor_rect[3]; + } else { + scissor.left = 0; + scissor.top = 0; + scissor.right = current_render_target_width_; + scissor.bottom = current_render_target_height_; + } + if (scissor.right <= scissor.left || scissor.bottom <= scissor.top) { + // Nothing is visible (used as the default current_scissor_ value also). + return; + } + if (current_scissor_.left != scissor.left || + current_scissor_.top != scissor.top || + current_scissor_.right != scissor.right || + current_scissor_.bottom != scissor.bottom) { + current_scissor_ = scissor; + current_command_list_->RSSetScissorRects(1, &scissor); + } + // Bind the texture. auto texture = reinterpret_cast(draw.texture_handle); ID3D12Resource* texture_resource; @@ -579,6 +609,7 @@ void D3D12ImmediateDrawer::Draw(const ImmediateDraw& draw) { current_command_list_->SetDescriptorHeaps(2, descriptor_heaps); } if (bind_texture) { + current_texture_ = texture; D3D12_SHADER_RESOURCE_VIEW_DESC texture_view_desc; texture_view_desc.Format = D3D12ImmediateTexture::kFormat; texture_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; @@ -598,7 +629,6 @@ void D3D12ImmediateDrawer::Draw(const ImmediateDraw& draw) { provider.OffsetViewDescriptor( texture_descriptor_pool_->GetLastRequestHeapGPUStart(), texture_descriptor_index)); - current_texture_ = texture; } // Bind the sampler. @@ -615,11 +645,11 @@ void D3D12ImmediateDrawer::Draw(const ImmediateDraw& draw) { sampler_index = SamplerIndex::kNearestClamp; } if (current_sampler_index_ != sampler_index) { + current_sampler_index_ = sampler_index; current_command_list_->SetGraphicsRootDescriptorTable( UINT(RootParameter::kSampler), provider.OffsetSamplerDescriptor(sampler_heap_gpu_start_, uint32_t(sampler_index))); - current_sampler_index_ = sampler_index; } // Set whether texture coordinates need to be restricted. @@ -645,27 +675,11 @@ void D3D12ImmediateDrawer::Draw(const ImmediateDraw& draw) { return; } if (current_primitive_topology_ != primitive_topology) { + current_primitive_topology_ = primitive_topology; current_command_list_->IASetPrimitiveTopology(primitive_topology); current_command_list_->SetPipelineState(pipeline); - current_primitive_topology_ = primitive_topology; } - // Set the scissor rectangle if enabled. - D3D12_RECT scissor; - if (draw.scissor) { - scissor.left = draw.scissor_rect[0]; - scissor.top = current_render_target_height_ - - (draw.scissor_rect[1] + draw.scissor_rect[3]); - scissor.right = scissor.left + draw.scissor_rect[2]; - scissor.bottom = scissor.top + draw.scissor_rect[3]; - } else { - scissor.left = 0; - scissor.top = 0; - scissor.right = current_render_target_width_; - scissor.bottom = current_render_target_height_; - } - current_command_list_->RSSetScissorRects(1, &scissor); - // Draw. if (batch_has_index_buffer_) { current_command_list_->DrawIndexedInstanced( diff --git a/src/xenia/ui/d3d12/d3d12_immediate_drawer.h b/src/xenia/ui/d3d12/d3d12_immediate_drawer.h index b18d87909..53ae81054 100644 --- a/src/xenia/ui/d3d12/d3d12_immediate_drawer.h +++ b/src/xenia/ui/d3d12/d3d12_immediate_drawer.h @@ -95,6 +95,7 @@ class D3D12ImmediateDrawer : public ImmediateDrawer { int current_render_target_width_, current_render_target_height_; bool batch_open_ = false; bool batch_has_index_buffer_; + D3D12_RECT current_scissor_; D3D_PRIMITIVE_TOPOLOGY current_primitive_topology_; ImmediateTexture* current_texture_; SamplerIndex current_sampler_index_; diff --git a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.cso b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.cso index 81917561c..5a4a854bf 100644 Binary files a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.cso and b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.cso differ diff --git a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.h b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.h index 03a09ce46..074264ab7 100644 --- a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.h +++ b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.h @@ -1,8 +1,8 @@ // generated from `xb buildhlsl` // source: immediate.vs.hlsl const uint8_t immediate_vs[] = { - 0x44, 0x58, 0x42, 0x43, 0x6A, 0xC1, 0xC3, 0xE8, 0xA7, 0x09, 0x30, 0xF3, - 0x48, 0x84, 0xA3, 0x3C, 0x7D, 0x90, 0xA1, 0x09, 0x01, 0x00, 0x00, 0x00, + 0x44, 0x58, 0x42, 0x43, 0xC3, 0x3E, 0x79, 0xCB, 0x09, 0x65, 0x04, 0xF0, + 0x71, 0x43, 0x47, 0x45, 0xAC, 0xE1, 0xA9, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00, 0xC4, 0x01, 0x00, 0x00, 0x34, 0x02, 0x00, 0x00, 0x64, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x18, 0x01, 0x00, 0x00, @@ -21,8 +21,8 @@ const uint8_t immediate_vs[] = { 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x78, 0x65, 0x5F, 0x76, - 0x69, 0x65, 0x77, 0x70, 0x6F, 0x72, 0x74, 0x5F, 0x69, 0x6E, 0x76, 0x5F, - 0x73, 0x69, 0x7A, 0x65, 0x00, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x32, 0x00, + 0x69, 0x65, 0x77, 0x70, 0x6F, 0x72, 0x74, 0x5F, 0x73, 0x69, 0x7A, 0x65, + 0x5F, 0x69, 0x6E, 0x76, 0x00, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x32, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00, diff --git a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.txt b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.txt index fe5f8134f..fbda7ff07 100644 --- a/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.txt +++ b/src/xenia/ui/shaders/bytecode/d3d12_5_1/immediate_vs.txt @@ -7,7 +7,7 @@ // cbuffer $Globals // { // -// float2 xe_viewport_inv_size; // Offset: 0 Size: 8 +// float2 xe_viewport_size_inv; // Offset: 0 Size: 8 // // } // diff --git a/src/xenia/ui/shaders/immediate.vs.hlsl b/src/xenia/ui/shaders/immediate.vs.hlsl index 2391d7c3b..a79da7b1c 100644 --- a/src/xenia/ui/shaders/immediate.vs.hlsl +++ b/src/xenia/ui/shaders/immediate.vs.hlsl @@ -14,10 +14,10 @@ struct XeVertexShaderOutput { XeVertexShaderOutput main(XeVertexShaderInput input) { XeVertexShaderOutput output; - output.texcoord = input.texcoord; - output.color = input.color; output.position = float4( input.position * xe_viewport_size_inv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0); + output.texcoord = input.texcoord; + output.color = input.color; return output; }