From 3106d0e3e2f1d86a75ed45671d8150d1d0e60042 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 5 Nov 2023 20:59:52 -0500 Subject: [PATCH] [host] DXGI: stop packing data across rows This is a precursor to allowing damage-aware RGB24 copies. --- .../Windows/capture/DXGI/src/pp/rgb24.c | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/host/platform/Windows/capture/DXGI/src/pp/rgb24.c b/host/platform/Windows/capture/DXGI/src/pp/rgb24.c index dd844ecb..ae8318cb 100644 --- a/host/platform/Windows/capture/DXGI/src/pp/rgb24.c +++ b/host/platform/Windows/capture/DXGI/src/pp/rgb24.c @@ -78,19 +78,15 @@ static bool rgb24_configure(void * opaque, if (!this.pshader) { - this.width = *cols; + this.width = *cols; this.height = *rows; - char sOutputWidth[6], sOutputHeight[6], sInputWidth[6], sInputHeight[6]; - snprintf(sInputWidth , sizeof(sInputWidth) , "%d", *width ); - snprintf(sInputHeight , sizeof(sInputHeight) , "%d", *height ); + char sOutputWidth[6], sOutputHeight[6]; snprintf(sOutputWidth , sizeof(sOutputWidth) , "%d", this.width ); snprintf(sOutputHeight, sizeof(sOutputHeight), "%d", this.height); const D3D_SHADER_MACRO defines[] = { - {"INPUT_WIDTH" , sInputWidth }, - {"INPUT_HEIGHT" , sInputHeight }, {"OUTPUT_WIDTH" , sOutputWidth }, {"OUTPUT_HEIGHT", sOutputHeight}, {NULL, NULL} @@ -103,26 +99,26 @@ static bool rgb24_configure(void * opaque, " float4 position : SV_POSITION,\n" " float2 texCoord : TEXCOORD0) : SV_TARGET\n" "{\n" - " uint outputIdx = uint(texCoord.y * OUTPUT_HEIGHT) * OUTPUT_WIDTH +\n" - " uint(texCoord.x * OUTPUT_WIDTH);\n" + " uint inputAndOutputY = uint(texCoord.y * OUTPUT_HEIGHT);\n" + " uint outputX = uint(texCoord.x * OUTPUT_WIDTH);\n" "\n" - " uint fst = (outputIdx * 4) / 3;\n" + " uint fstInputX = (outputX * 4) / 3;\n" " float4 color0 = gInputTexture.Load(\n" - " uint3(fst % INPUT_WIDTH, fst / INPUT_WIDTH, 0));\n" + " uint3(fstInputX, inputAndOutputY, 0));\n" "\n" - " uint snd = fst + 1;\n" + " uint sndInputX = fstInputX + 1;\n" " float4 color3 = gInputTexture.Load(\n" - " uint3(snd % INPUT_WIDTH, snd / INPUT_WIDTH, 0));\n" + " uint3(sndInputX, inputAndOutputY, 0));\n" "\n" - " uint outputIdxMod3 = outputIdx % 3;\n" + " uint outputXMod3 = outputX % 3;\n" "\n" - " float4 color1 = outputIdxMod3 <= 1 ? color0 : color3;\n" - " float4 color2 = outputIdxMod3 == 0 ? color0 : color3;\n" + " float4 color1 = outputXMod3 <= 1 ? color0 : color3;\n" + " float4 color2 = outputXMod3 == 0 ? color0 : color3;\n" "\n" - " float b = color0.bgr[outputIdxMod3];\n" - " float g = color1.grb[outputIdxMod3];\n" - " float r = color2.rbg[outputIdxMod3];\n" - " float a = color3.bgr[outputIdxMod3];\n" + " float b = color0.bgr[outputXMod3];\n" + " float g = color1.grb[outputXMod3];\n" + " float r = color2.rbg[outputXMod3];\n" + " float a = color3.bgr[outputXMod3];\n" " return float4(r, g, b, a);\n" "}\n";