Commit 53096e48 by Antonio Maiorano

Use correct values for sampleStandardLocations

Bug: b/141380498 Change-Id: I25c6bf769c558fb4bc3a3a64f66289cf5dbfb879 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36595Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 03646345
...@@ -1295,7 +1295,7 @@ namespace sw ...@@ -1295,7 +1295,7 @@ namespace sw
void Blitter::ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled) void Blitter::ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled)
{ {
float4 scale, unscale; float4 scale{}, unscale{};
if(state.clearOperation && if(state.clearOperation &&
state.sourceFormat.isNonNormalizedInteger() && state.sourceFormat.isNonNormalizedInteger() &&
......
...@@ -290,17 +290,43 @@ namespace sw ...@@ -290,17 +290,43 @@ namespace sw
sRGBtoLinear12_16[i] = (unsigned short)(clamp(sw::sRGBtoLinear((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF)); sRGBtoLinear12_16[i] = (unsigned short)(clamp(sw::sRGBtoLinear((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
} }
// VK_SAMPLE_COUNT_4_BIT
// https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#primsrast-multisampling
constexpr float sampleLocations4[][2] = {
{0.375, 0.125},
{0.875, 0.375},
{0.125, 0.625},
{0.625, 0.875},
};
// Vulkan spec sample positions are relative to 0,0 in top left corner, with Y+ going down.
// Convert to our space, with 0,0 in center, and Y+ going up.
constexpr float4 X[4] = {
sw::replicate(sampleLocations4[0][0] - 0.5f), // -0.125
sw::replicate(sampleLocations4[1][0] - 0.5f), // +0.375
sw::replicate(sampleLocations4[2][0] - 0.5f), // -0.375
sw::replicate(sampleLocations4[3][0] - 0.5f), // +0.125
};
constexpr float4 Y[4] = {
sw::replicate(-(sampleLocations4[0][1] - 0.5f)), // +0.375
sw::replicate(-(sampleLocations4[1][1] - 0.5f)), // +0.125
sw::replicate(-(sampleLocations4[2][1] - 0.5f)), // -0.125
sw::replicate(-(sampleLocations4[3][1] - 0.5f)), // -0.375
};
for(int q = 0; q < 4; q++) for(int q = 0; q < 4; q++)
{ {
for(int c = 0; c < 16; c++) for(int c = 0; c < 16; c++)
{ {
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {
const float X[4] = {+0.3125f, -0.3125f, -0.1250f, +0.1250f}; // Reorder sample points for centroid computation
const float Y[4] = {+0.1250f, -0.1250f, +0.3125f, -0.3125f}; const float Xs[4] = { X[1][0], X[2][0], X[0][0], X[3][0] };
const float Ys[4] = { Y[1][0], Y[2][0], Y[0][0], Y[3][0] };
sampleX[q][c][i] = c & (1 << i) ? X[q] : 0.0f; sampleX[q][c][i] = c & (1 << i) ? Xs[q] : 0.0f;
sampleY[q][c][i] = c & (1 << i) ? Y[q] : 0.0f; sampleY[q][c][i] = c & (1 << i) ? Ys[q] : 0.0f;
weight[c][i] = c & (1 << i) ? 1.0f : 0.0f; weight[c][i] = c & (1 << i) ? 1.0f : 0.0f;
} }
} }
...@@ -312,16 +338,6 @@ namespace sw ...@@ -312,16 +338,6 @@ namespace sw
memcpy(&this->Xf, &Xf, sizeof(Xf)); memcpy(&this->Xf, &Xf, sizeof(Xf));
memcpy(&this->Yf, &Yf, sizeof(Yf)); memcpy(&this->Yf, &Yf, sizeof(Yf));
static const float4 X[4] = {{-0.3125f, -0.3125f, -0.3125f, -0.3125f},
{+0.3125f, +0.3125f, +0.3125f, +0.3125f},
{+0.1250f, +0.1250f, +0.1250f, +0.1250f},
{-0.1250f, -0.1250f, -0.1250f, -0.1250f}};
static const float4 Y[4] = {{-0.1250f, -0.1250f, -0.1250f, -0.1250f},
{+0.1250f, +0.1250f, +0.1250f, +0.1250f},
{-0.3125f, -0.3125f, -0.3125f, -0.3125f},
{+0.3125f, +0.3125f, +0.3125f, +0.3125f}};
memcpy(&this->X, &X, sizeof(X)); memcpy(&this->X, &X, sizeof(X));
memcpy(&this->Y, &Y, sizeof(Y)); memcpy(&this->Y, &Y, sizeof(Y));
......
...@@ -127,28 +127,14 @@ namespace sw ...@@ -127,28 +127,14 @@ namespace sw
} }
}); });
inline float4 vector(float x, float y, float z, float w) inline constexpr float4 vector(float x, float y, float z, float w)
{ {
float4 v; return { x, y, z, w };
v.x = x;
v.y = y;
v.z = z;
v.w = w;
return v;
} }
inline float4 replicate(float f) inline constexpr float4 replicate(float f)
{ {
float4 v; return vector(f, f, f, f);
v.x = f;
v.y = f;
v.z = f;
v.w = f;
return v;
} }
#define OFFSET(s,m) (int)(size_t)&reinterpret_cast<const volatile char&>((((s*)0)->m)) #define OFFSET(s,m) (int)(size_t)&reinterpret_cast<const volatile char&>((((s*)0)->m))
......
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