Commit 56f256e7 by Alexis Hetu Committed by Alexis Hétu

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/10828Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent facada53
......@@ -33,6 +33,7 @@ namespace sw
bool fullPixelPositionRegister = false;
bool leadingVertexFirst = false; // Flat shading uses first vertex, else last
bool secondaryColor = false; // Specular lighting is applied after texturing
bool colorsDefaultToZero = false;
bool forceWindowed = false;
bool quadLayoutEnabled = false;
......
......@@ -48,6 +48,7 @@ namespace sw
extern bool fullPixelPositionRegister;
extern bool leadingVertexFirst; // Flat shading uses first vertex, else last
extern bool secondaryColor; // Specular lighting is applied after texturing
extern bool colorsDefaultToZero;
extern bool forceWindowed;
extern bool complementaryDepthBuffer;
......@@ -110,6 +111,7 @@ namespace sw
sw::fullPixelPositionRegister = conventions.fullPixelPositionRegister;
sw::leadingVertexFirst = conventions.leadingVertexFirst;
sw::secondaryColor = conventions.secondaryColor;
sw::colorsDefaultToZero = conventions.colorsDefaultToZero;
sw::exactColorRounding = exactColorRounding;
setRenderTarget(0, 0);
......
......@@ -65,6 +65,7 @@ namespace sw
bool fullPixelPositionRegister;
bool leadingVertexFirst;
bool secondaryColor;
bool colorsDefaultToZero;
};
static const Conventions OpenGL =
......@@ -74,7 +75,8 @@ namespace sw
true, // booleanFaceRegister
true, // fullPixelPositionRegister
false, // leadingVertexFirst
false // secondaryColor
false, // secondaryColor
true, // colorsDefaultToZero
};
static const Conventions Direct3D =
......@@ -85,6 +87,7 @@ namespace sw
false, // fullPixelPositionRegister
true, // leadingVertexFirst
true, // secondardyColor
false, // colorsDefaultToZero
};
struct Query
......
......@@ -50,6 +50,8 @@ namespace
namespace sw
{
extern bool colorsDefaultToZero;
SamplerCore::SamplerCore(Pointer<Byte> &constants, const Sampler::State &state) : constants(constants), state(state)
{
}
......@@ -186,6 +188,7 @@ namespace sw
if(fixed12 && state.textureFilter != FILTER_GATHER)
{
int componentCount = textureComponentCount();
short defaultColorValue = colorsDefaultToZero ? 0x0000 : 0x1000;
switch(state.textureFormat)
{
......@@ -237,8 +240,8 @@ namespace sw
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 @@ namespace sw
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 @@ namespace sw
}
int componentCount = textureComponentCount();
float defaultColorValue = colorsDefaultToZero ? 0.0f : 1.0f;
if(state.textureFilter != FILTER_GATHER)
{
......@@ -495,8 +499,8 @@ namespace sw
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 @@ namespace sw
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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment