From 158c12ceb0c071b63240092ae28ddf41ebe4010c Mon Sep 17 00:00:00 2001 From: shadielhajj Date: Sun, 7 Jul 2024 15:43:13 +0100 Subject: [PATCH] Const matrices were being optimised away by the hlsl compiler (missing static keyword). --- color/space/YPbPr2rgb.hlsl | 4 ++-- color/space/lms2rgb.hlsl | 4 ++-- color/space/oklab2rgb.hlsl | 4 ++-- color/space/rgb2YPbPr.hlsl | 4 ++-- color/space/rgb2lms.hlsl | 4 ++-- color/space/rgb2oklab.hlsl | 4 ++-- color/space/rgb2yiq.hlsl | 2 +- color/space/rgb2yuv.hlsl | 4 ++-- color/space/xyz2rgb.hlsl | 4 ++-- color/space/yiq2rgb.hlsl | 2 +- color/space/yuv2rgb.hlsl | 4 ++-- generative/psrdnoise.hlsl | 8 ++++---- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/color/space/YPbPr2rgb.hlsl b/color/space/YPbPr2rgb.hlsl index f588f1d6..24c52afc 100644 --- a/color/space/YPbPr2rgb.hlsl +++ b/color/space/YPbPr2rgb.hlsl @@ -10,13 +10,13 @@ license: #ifndef MAT_YPBPR2RGB #define MAT_YPBPR2RGB #ifdef YPBPR_SDTV -const float3x3 YPBPR2RGB = float3x3( +static const float3x3 YPBPR2RGB = float3x3( 1.0, 1.0, 1.0, 0.0, -0.344, 1.772, 1.402, -0.714, 0.0 ); #else -const float3x3 YPBPR2RGB = float3x3( +static const float3x3 YPBPR2RGB = float3x3( 1.0, 1.0, 1.0, 0.0, -0.187, 1.856, 1.575, -0.468, 0.0 diff --git a/color/space/lms2rgb.hlsl b/color/space/lms2rgb.hlsl index 02941a5b..9b8931d0 100644 --- a/color/space/lms2rgb.hlsl +++ b/color/space/lms2rgb.hlsl @@ -12,12 +12,12 @@ license: #ifndef MAT_LMS2RGB #define MAT_LMS2RGB -// const float3x3 LMS2RGB = float3x3( +// static const float3x3 LMS2RGB = float3x3( // 2.85847e+0, -1.62879e+0, -2.48910e-2, // -2.10182e-1, 1.15820e+0, 3.24281e-4, // -4.18120e-2, -1.18169e-1, 1.06867e+0 // ); -const float3x3 LMS2RGB = float3x3( +static const float3x3 LMS2RGB = float3x3( 0.0809444479, -0.0102485335, -0.000365296938, -0.13050440, 0.0540193266, -0.00412161469, 0.116721066, -0.113614708, 0.693511405 diff --git a/color/space/oklab2rgb.hlsl b/color/space/oklab2rgb.hlsl index fcbe8d0a..939b76cf 100644 --- a/color/space/oklab2rgb.hlsl +++ b/color/space/oklab2rgb.hlsl @@ -8,12 +8,12 @@ license: #ifndef MAT_OKLAB2RGB #define MAT_OKLAB2RGB -const float3x3 OKLAB2RGB_A = float3x3( +static const float3x3 OKLAB2RGB_A = float3x3( 1.0, 1.0, 1.0, 0.3963377774, -0.1055613458, -0.0894841775, 0.2158037573, -0.0638541728, -1.2914855480); -const float3x3 OKLAB2RGB_B = float3x3( +static const float3x3 OKLAB2RGB_B = float3x3( 4.0767416621, -1.2684380046, -0.0041960863, -3.3077115913, 2.6097574011, -0.7034186147, 0.2309699292, -0.3413193965, 1.7076147010); diff --git a/color/space/rgb2YPbPr.hlsl b/color/space/rgb2YPbPr.hlsl index a9d45f63..206d4893 100644 --- a/color/space/rgb2YPbPr.hlsl +++ b/color/space/rgb2YPbPr.hlsl @@ -10,13 +10,13 @@ license: #ifndef MAT_RGB2PBPR #define MAT_RGB2PBPR #ifdef YPBPR_SDTV -const float3x3 RGB2PBPR = float3x3( +static const float3x3 RGB2PBPR = float3x3( .299, -.169, .5, .587, -.331, -.419, .114, .5, -.081 ); #else -const float3x3 RGB2PBPR = float3x3( +static const float3x3 RGB2PBPR = float3x3( 0.2126, -0.1145721060573399, 0.5, 0.7152, -0.3854278939426601, -0.4541529083058166, 0.0722, 0.5, -0.0458470916941834 diff --git a/color/space/rgb2lms.hlsl b/color/space/rgb2lms.hlsl index 169f3a38..c69fd27e 100644 --- a/color/space/rgb2lms.hlsl +++ b/color/space/rgb2lms.hlsl @@ -12,13 +12,13 @@ license: #ifndef MAT_RGB2LMS #define MAT_RGB2LMS -// const float3x3 RGB2LMS = float3x3( +// static const float3x3 RGB2LMS = float3x3( // 3.90405e-1, 5.49941e-1, 8.92632e-3, // 7.08416e-2, 9.63172e-1, 1.35775e-3, // 2.31082e-2, 1.28021e-1, 9.36245e-1 // ); -const float3x3 RGB2LMS = float3x3( +static const float3x3 RGB2LMS = float3x3( 17.8824, 3.45565, 0.0299566, 43.5161, 27.1554, 0.184309, 4.11935, 0.184309, 1.46709 diff --git a/color/space/rgb2oklab.hlsl b/color/space/rgb2oklab.hlsl index 489956d7..15d56b46 100644 --- a/color/space/rgb2oklab.hlsl +++ b/color/space/rgb2oklab.hlsl @@ -9,12 +9,12 @@ license: #ifndef MAT_RGB2OKLAB #define MAT_RGB2OKLAB -const float3x3 RGB2OKLAB_A = float3x3( +static const float3x3 RGB2OKLAB_A = float3x3( 0.2104542553, 1.9779984951, 0.0259040371, 0.7936177850, -2.4285922050, 0.7827717662, -0.0040720468, 0.4505937099, -0.8086757660); -const float3x3 RGB2OKLAB_B = float3x3( +static const float3x3 RGB2OKLAB_B = float3x3( 0.4122214708, 0.2119034982, 0.0883024619, 0.5363325363, 0.6806995451, 0.2817188376, 0.0514459929, 0.1073969566, 0.6299787005); diff --git a/color/space/rgb2yiq.hlsl b/color/space/rgb2yiq.hlsl index cfb0815c..e7d32b84 100644 --- a/color/space/rgb2yiq.hlsl +++ b/color/space/rgb2yiq.hlsl @@ -9,7 +9,7 @@ license: #ifndef MAT_RGB2YIQ #define MAT_RGB2YIQ -const float3x3 RGB2YIQ = float3x3( +static const float3x3 RGB2YIQ = float3x3( 0.300, 0.5900, 0.1100, 0.599, -0.2773, -0.3217, 0.213, -0.5251, 0.3121); diff --git a/color/space/rgb2yuv.hlsl b/color/space/rgb2yuv.hlsl index 90a93efe..f2385a25 100644 --- a/color/space/rgb2yuv.hlsl +++ b/color/space/rgb2yuv.hlsl @@ -10,13 +10,13 @@ license: #ifndef MAT_RGB2YUV #define MAT_RGB2YUV #ifdef YUV_SDTV -const float3x3 RGB2YUV = float3x3( +static const float3x3 RGB2YUV = float3x3( 0.299, -0.14713, 0.615, 0.587, -0.28886, -0.51499, 0.114, 0.436, -0.10001 ); #else -const float3x3 RGB2YUV = float3x3( +static const float3x3 RGB2YUV = float3x3( 0.2126, -0.09991, 0.615, 0.7152, -0.33609,-0.55861, 0.0722, 0.426, -0.05639 diff --git a/color/space/xyz2rgb.hlsl b/color/space/xyz2rgb.hlsl index 9efb59a9..c25060c9 100644 --- a/color/space/xyz2rgb.hlsl +++ b/color/space/xyz2rgb.hlsl @@ -10,14 +10,14 @@ license: #ifndef MAT_XYZ2RGB #define MAT_XYZ2RGB #ifdef CIE_D50 -const float3x3 XYZ2RGB = float3x3( +static const float3x3 XYZ2RGB = float3x3( 3.1338561,-0.9787684, 0.0719453, -1.6168667, 1.9161415,-0.2289914, -0.4906146, 0.0334540, 1.4052427 ); #else // CIE D65 -const float3x3 XYZ2RGB = float3x3( +static const float3x3 XYZ2RGB = float3x3( 3.2404542,-0.9692660, 0.0556434, -1.5371385, 1.8760108,-0.2040259, -0.4985314, 0.0415560, 1.0572252 diff --git a/color/space/yiq2rgb.hlsl b/color/space/yiq2rgb.hlsl index 8d3f1c1a..e022a6b8 100644 --- a/color/space/yiq2rgb.hlsl +++ b/color/space/yiq2rgb.hlsl @@ -9,7 +9,7 @@ license: #ifndef MAT_YIQ2RGB #define MAT_YIQ2RGB -const float3x3 YIQ2RGB = float3x3( 1.0, 0.9469, 0.6235, +static const float3x3 YIQ2RGB = float3x3( 1.0, 0.9469, 0.6235, 1.0, -0.2747, -0.6357, 1.0, -1.1085, 1.7020 ); #endif diff --git a/color/space/yuv2rgb.hlsl b/color/space/yuv2rgb.hlsl index d9e4be40..eb54e3ae 100644 --- a/color/space/yuv2rgb.hlsl +++ b/color/space/yuv2rgb.hlsl @@ -10,13 +10,13 @@ license: #ifndef MAT_YUV2RGB #define MAT_YUV2RGB #ifdef YUV_SDTV -const float3x3 YUV2RGB = float3x3( +static const float3x3 YUV2RGB = float3x3( 1.0, 1.0, 1.0, 0.0, -0.39465, 2.03211, 1.13983, -0.58060, 0.0 ); #else -const float3x3 YUV2RGB = float3x3( +static const float3x3 YUV2RGB = float3x3( 1.0, 1.0, 1.0, 0.0, -0.21482, 2.12798, 1.28033, -0.38059, 0.0 diff --git a/generative/psrdnoise.hlsl b/generative/psrdnoise.hlsl index 1c02d361..03c15e6b 100644 --- a/generative/psrdnoise.hlsl +++ b/generative/psrdnoise.hlsl @@ -228,11 +228,11 @@ float psrdnoise(float3 x, float3 period, float alpha, out float3 gradient) { #ifndef PSRDNOISE_PERLIN_GRID // Transformation matrices for the axis-aligned simplex grid - const float3x3 M = float3x3(0.0, 1.0, 1.0, + static const float3x3 M = float3x3(0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0); - const float3x3 Mi = float3x3(-0.5, 0.5, 0.5, + static const float3x3 Mi = float3x3(-0.5, 0.5, 0.5, 0.5,-0.5, 0.5, 0.5, 0.5,-0.5); #endif @@ -431,11 +431,11 @@ float psrdnoise(float3 x, float3 period, float alpha, out float3 gradient, out f #ifndef PSRDNOISE_PERLIN_GRID // Transformation matrices for the axis-aligned simplex grid - const float3x3 M = float3x3(0.0, 1.0, 1.0, + static const float3x3 M = float3x3(0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0); - const float3x3 Mi = float3x3(-0.5, 0.5, 0.5, + static const float3x3 Mi = float3x3(-0.5, 0.5, 0.5, 0.5,-0.5, 0.5, 0.5, 0.5,-0.5); #endif