Fixed default color values for R and RG types
By default, in D3D, R, G or B channels default to 1 when no
value is assigned to them. In OpenGL, these channels default
to 0. Added an entry to Conventions to fix this issue.
In dEQP, this fixes all R and RG types tests from:
functional.texture.format.*
Change-Id: Ib5552aa36eaf4e3e1132f016f002250b40436227
Reviewed-on: https://swiftshader-review.googlesource.com/10828
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index f0d482f..0ee9014 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -50,6 +50,8 @@
namespace sw
{
+ extern bool colorsDefaultToZero;
+
SamplerCore::SamplerCore(Pointer<Byte> &constants, const Sampler::State &state) : constants(constants), state(state)
{
}
@@ -186,6 +188,7 @@
if(fixed12 && state.textureFilter != FILTER_GATHER)
{
int componentCount = textureComponentCount();
+ short defaultColorValue = colorsDefaultToZero ? 0x0000 : 0x1000;
switch(state.textureFormat)
{
@@ -237,8 +240,8 @@
case FORMAT_YV12_BT601:
case FORMAT_YV12_BT709:
case FORMAT_YV12_JFIF:
- if(componentCount < 2) c.y = Short4(0x1000);
- if(componentCount < 3) c.z = Short4(0x1000);
+ if(componentCount < 2) c.y = Short4(defaultColorValue);
+ if(componentCount < 3) c.z = Short4(defaultColorValue);
if(componentCount < 4) c.w = Short4(0x1000);
break;
case FORMAT_A8:
@@ -259,9 +262,9 @@
c.z = c.x;
break;
case FORMAT_R32F:
- c.y = Short4(0x1000);
+ c.y = Short4(defaultColorValue);
case FORMAT_G32R32F:
- c.z = Short4(0x1000);
+ c.z = Short4(defaultColorValue);
case FORMAT_X32B32G32R32F:
c.w = Short4(0x1000);
case FORMAT_A32B32G32R32F:
@@ -438,6 +441,7 @@
}
int componentCount = textureComponentCount();
+ float defaultColorValue = colorsDefaultToZero ? 0.0f : 1.0f;
if(state.textureFilter != FILTER_GATHER)
{
@@ -495,8 +499,8 @@
case FORMAT_YV12_BT601:
case FORMAT_YV12_BT709:
case FORMAT_YV12_JFIF:
- if(componentCount < 2) c.y = Float4(1.0f);
- if(componentCount < 3) c.z = Float4(1.0f);
+ if(componentCount < 2) c.y = Float4(defaultColorValue);
+ if(componentCount < 3) c.z = Float4(defaultColorValue);
if(componentCount < 4) c.w = Float4(1.0f);
break;
case FORMAT_A8:
@@ -517,9 +521,9 @@
c.z = c.x;
break;
case FORMAT_R32F:
- c.y = Float4(1.0f);
+ c.y = Float4(defaultColorValue);
case FORMAT_G32R32F:
- c.z = Float4(1.0f);
+ c.z = Float4(defaultColorValue);
case FORMAT_X32B32G32R32F:
c.w = Float4(1.0f);
case FORMAT_A32B32G32R32F: