Commit a7a37556 by Chris Forbes

Wire up NoPerspective to interpolation

Also jettison all the context-level perspective enable plumbing; it serves no purpose in Vulkan. Test: dEQP-VK.spirv_assembly.instruction.graphics.cross_stage.* Change-Id: If823c099a82750a57bca16f04ff2ddbeee3a8f45 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31228 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent a19080a9
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
namespace sw namespace sw
{ {
extern bool perspectiveCorrection;
bool booleanFaceRegister = false; bool booleanFaceRegister = false;
bool fullPixelPositionRegister = false; bool fullPixelPositionRegister = false;
...@@ -619,26 +617,6 @@ namespace sw ...@@ -619,26 +617,6 @@ namespace sw
} }
} }
bool Context::perspectiveActive() const
{
if(!colorUsed())
{
return false;
}
if(!perspectiveCorrection)
{
return false;
}
if(isDrawPoint())
{
return false;
}
return true;
}
VkFormat Context::renderTargetInternalFormat(int index) const VkFormat Context::renderTargetInternalFormat(int index) const
{ {
if(renderTarget[index]) if(renderTarget[index])
......
...@@ -121,8 +121,6 @@ namespace sw ...@@ -121,8 +121,6 @@ namespace sw
bool depthBufferActive() const; bool depthBufferActive() const;
bool stencilActive() const; bool stencilActive() const;
bool perspectiveActive() const;
bool allTargetsColorClamp() const; bool allTargetsColorClamp() const;
bool alphaBlendActive() const; bool alphaBlendActive() const;
VkBlendFactor sourceBlendFactor() const; VkBlendFactor sourceBlendFactor() const;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
namespace sw namespace sw
{ {
extern TransparencyAntialiasing transparencyAntialiasing; extern TransparencyAntialiasing transparencyAntialiasing;
extern bool perspectiveCorrection;
bool precachePixel = false; bool precachePixel = false;
...@@ -164,11 +163,6 @@ namespace sw ...@@ -164,11 +163,6 @@ namespace sw
factor.invBlendConstant4F[3][3] = 1 - blendConstant.a; factor.invBlendConstant4F[3][3] = 1 - blendConstant.a;
} }
void PixelProcessor::setPerspectiveCorrection(bool perspectiveEnable)
{
perspectiveCorrection = perspectiveEnable;
}
void PixelProcessor::setRoutineCacheSize(int cacheSize) void PixelProcessor::setRoutineCacheSize(int cacheSize)
{ {
delete routineCache; delete routineCache;
...@@ -208,8 +202,6 @@ namespace sw ...@@ -208,8 +202,6 @@ namespace sw
} }
state.occlusionEnabled = context->occlusionEnabled; state.occlusionEnabled = context->occlusionEnabled;
state.perspective = context->perspectiveActive();
state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f); state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f);
if(context->alphaBlendActive()) if(context->alphaBlendActive())
......
...@@ -126,8 +126,6 @@ namespace sw ...@@ -126,8 +126,6 @@ namespace sw
void setBlendConstant(const Color<float> &blendConstant); void setBlendConstant(const Color<float> &blendConstant);
void setPerspectiveCorrection(bool perspectiveCorrection);
protected: protected:
const State update(const Context* context) const; const State update(const Context* context) const;
Routine *routine(const State &state, vk::PipelineLayout const *pipelineLayout, Routine *routine(const State &state, vk::PipelineLayout const *pipelineLayout,
......
...@@ -257,6 +257,8 @@ namespace sw ...@@ -257,6 +257,8 @@ namespace sw
bool QuadRasterizer::interpolateW() const bool QuadRasterizer::interpolateW() const
{ {
return state.perspective || (spirvShader && spirvShader->hasBuiltinInput(spv::BuiltInPosition)); // Note: could optimize cases where there is a fragment shader but it has no
// perspective-correct inputs, but that's vanishingly rare.
return spirvShader != nullptr;
} }
} }
...@@ -68,7 +68,6 @@ namespace sw ...@@ -68,7 +68,6 @@ namespace sw
TranscendentalPrecision expPrecision = ACCURATE; TranscendentalPrecision expPrecision = ACCURATE;
TranscendentalPrecision rcpPrecision = ACCURATE; TranscendentalPrecision rcpPrecision = ACCURATE;
TranscendentalPrecision rsqPrecision = ACCURATE; TranscendentalPrecision rsqPrecision = ACCURATE;
bool perspectiveCorrection = true;
static void setGlobalRenderingSettings(Conventions conventions, bool exactColorRounding) static void setGlobalRenderingSettings(Conventions conventions, bool exactColorRounding)
{ {
...@@ -1470,8 +1469,6 @@ namespace sw ...@@ -1470,8 +1469,6 @@ namespace sw
PixelProcessor::setRoutineCacheSize(configuration.pixelRoutineCacheSize); PixelProcessor::setRoutineCacheSize(configuration.pixelRoutineCacheSize);
SetupProcessor::setRoutineCacheSize(configuration.setupRoutineCacheSize); SetupProcessor::setRoutineCacheSize(configuration.setupRoutineCacheSize);
setPerspectiveCorrection(configuration.perspectiveCorrection);
switch(configuration.transcendentalPrecision) switch(configuration.transcendentalPrecision)
{ {
case 0: case 0:
......
...@@ -57,7 +57,6 @@ namespace sw ...@@ -57,7 +57,6 @@ namespace sw
extern TranscendentalPrecision expPrecision; extern TranscendentalPrecision expPrecision;
extern TranscendentalPrecision rcpPrecision; extern TranscendentalPrecision rcpPrecision;
extern TranscendentalPrecision rsqPrecision; extern TranscendentalPrecision rsqPrecision;
extern bool perspectiveCorrection;
struct Conventions // FIXME(capn): Eliminate. Only support Vulkan 1.1 conventions. struct Conventions // FIXME(capn): Eliminate. Only support Vulkan 1.1 conventions.
{ {
......
...@@ -79,8 +79,7 @@ namespace sw ...@@ -79,8 +79,7 @@ namespace sw
state.isDrawLine = context->isDrawLine(); state.isDrawLine = context->isDrawLine();
state.isDrawTriangle = context->isDrawTriangle(); state.isDrawTriangle = context->isDrawTriangle();
state.interpolateZ = context->depthBufferActive() || vPosZW; state.interpolateZ = context->depthBufferActive() || vPosZW;
state.interpolateW = context->perspectiveActive() || vPosZW; state.interpolateW = context->pixelShader != nullptr;
state.perspective = context->perspectiveActive();
state.frontFacingCCW = context->frontFacingCCW; state.frontFacingCCW = context->frontFacingCCW;
state.cullMode = context->cullMode; state.cullMode = context->cullMode;
state.twoSidedStencil = context->stencilActive() && context->twoSidedStencil; state.twoSidedStencil = context->stencilActive() && context->twoSidedStencil;
......
...@@ -41,7 +41,6 @@ namespace sw ...@@ -41,7 +41,6 @@ namespace sw
bool isDrawTriangle : 1; bool isDrawTriangle : 1;
bool interpolateZ : 1; bool interpolateZ : 1;
bool interpolateW : 1; bool interpolateW : 1;
bool perspective : 1;
bool frontFacingCCW : 1; bool frontFacingCCW : 1;
VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM); VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM);
bool twoSidedStencil : 1; bool twoSidedStencil : 1;
......
...@@ -352,11 +352,6 @@ namespace sw ...@@ -352,11 +352,6 @@ namespace sw
html += "<option value='1'" + (config.mipmapQuality == 1 ? selected : empty) + ">Linear (default)</option>\n"; html += "<option value='1'" + (config.mipmapQuality == 1 ? selected : empty) + ">Linear (default)</option>\n";
html += "</select></td>\n"; html += "</select></td>\n";
html += "</tr>\n"; html += "</tr>\n";
html += "<tr><td>Perspective correction:</td><td><select name='perspectiveCorrection' title='Enables or disables perspective correction. Disabling it is faster but can causes distortion. Recommended for 2D applications only.'>\n";
html += "<option value='0'" + (config.perspectiveCorrection == 0 ? selected : empty) + ">Off</option>\n";
html += "<option value='1'" + (config.perspectiveCorrection == 1 ? selected : empty) + ">On (default)</option>\n";
html += "</select></td>\n";
html += "</tr>\n";
html += "<tr><td>Transcendental function precision:</td><td><select name='transcendentalPrecision' title='The precision at which log/exp/pow/rcp/rsq/nrm shader instructions are computed. Lower settings can be faster but cause visual artifacts.'>\n"; html += "<tr><td>Transcendental function precision:</td><td><select name='transcendentalPrecision' title='The precision at which log/exp/pow/rcp/rsq/nrm shader instructions are computed. Lower settings can be faster but cause visual artifacts.'>\n";
html += "<option value='0'" + (config.transcendentalPrecision == 0 ? selected : empty) + ">Approximate</option>\n"; html += "<option value='0'" + (config.transcendentalPrecision == 0 ? selected : empty) + ">Approximate</option>\n";
html += "<option value='1'" + (config.transcendentalPrecision == 1 ? selected : empty) + ">Partial</option>\n"; html += "<option value='1'" + (config.transcendentalPrecision == 1 ? selected : empty) + ">Partial</option>\n";
...@@ -592,10 +587,6 @@ namespace sw ...@@ -592,10 +587,6 @@ namespace sw
{ {
config.mipmapQuality = integer; config.mipmapQuality = integer;
} }
else if(sscanf(post, "perspectiveCorrection=%d", &integer))
{
config.perspectiveCorrection = integer != 0;
}
else if(sscanf(post, "transcendentalPrecision=%d", &integer)) else if(sscanf(post, "transcendentalPrecision=%d", &integer))
{ {
config.transcendentalPrecision = integer; config.transcendentalPrecision = integer;
...@@ -721,7 +712,6 @@ namespace sw ...@@ -721,7 +712,6 @@ namespace sw
config.vertexCacheSize = ini.getInteger("Caches", "VertexCacheSize", 64); config.vertexCacheSize = ini.getInteger("Caches", "VertexCacheSize", 64);
config.textureSampleQuality = ini.getInteger("Quality", "TextureSampleQuality", 2); config.textureSampleQuality = ini.getInteger("Quality", "TextureSampleQuality", 2);
config.mipmapQuality = ini.getInteger("Quality", "MipmapQuality", 1); config.mipmapQuality = ini.getInteger("Quality", "MipmapQuality", 1);
config.perspectiveCorrection = ini.getBoolean("Quality", "PerspectiveCorrection", true);
config.transcendentalPrecision = ini.getInteger("Quality", "TranscendentalPrecision", 2); config.transcendentalPrecision = ini.getInteger("Quality", "TranscendentalPrecision", 2);
config.transparencyAntialiasing = ini.getInteger("Quality", "TransparencyAntialiasing", 0); config.transparencyAntialiasing = ini.getInteger("Quality", "TransparencyAntialiasing", 0);
config.threadCount = ini.getInteger("Processor", "ThreadCount", DEFAULT_THREAD_COUNT); config.threadCount = ini.getInteger("Processor", "ThreadCount", DEFAULT_THREAD_COUNT);
...@@ -778,7 +768,6 @@ namespace sw ...@@ -778,7 +768,6 @@ namespace sw
ini.addValue("Caches", "VertexCacheSize", itoa(config.vertexCacheSize)); ini.addValue("Caches", "VertexCacheSize", itoa(config.vertexCacheSize));
ini.addValue("Quality", "TextureSampleQuality", itoa(config.textureSampleQuality)); ini.addValue("Quality", "TextureSampleQuality", itoa(config.textureSampleQuality));
ini.addValue("Quality", "MipmapQuality", itoa(config.mipmapQuality)); ini.addValue("Quality", "MipmapQuality", itoa(config.mipmapQuality));
ini.addValue("Quality", "PerspectiveCorrection", itoa(config.perspectiveCorrection));
ini.addValue("Quality", "TranscendentalPrecision", itoa(config.transcendentalPrecision)); ini.addValue("Quality", "TranscendentalPrecision", itoa(config.transcendentalPrecision));
ini.addValue("Quality", "TransparencyAntialiasing", itoa(config.transparencyAntialiasing)); ini.addValue("Quality", "TransparencyAntialiasing", itoa(config.transparencyAntialiasing));
ini.addValue("Processor", "ThreadCount", itoa(config.threadCount)); ini.addValue("Processor", "ThreadCount", itoa(config.threadCount));
......
...@@ -40,7 +40,6 @@ namespace sw ...@@ -40,7 +40,6 @@ namespace sw
int vertexCacheSize; int vertexCacheSize;
int textureSampleQuality; int textureSampleQuality;
int mipmapQuality; int mipmapQuality;
bool perspectiveCorrection;
int transcendentalPrecision; int transcendentalPrecision;
int threadCount; int threadCount;
bool enableSSE; bool enableSSE;
......
...@@ -161,14 +161,14 @@ namespace sw ...@@ -161,14 +161,14 @@ namespace sw
routine.inputs[interpolant] = routine.inputs[interpolant] =
interpolateCentroid(XXXX, YYYY, rhwCentroid, interpolateCentroid(XXXX, YYYY, rhwCentroid,
primitive + OFFSET(Primitive, V[interpolant]), primitive + OFFSET(Primitive, V[interpolant]),
input.Flat, state.perspective); input.Flat, !input.NoPerspective);
} }
else else
{ {
routine.inputs[interpolant] = routine.inputs[interpolant] =
interpolate(xxxx, Dv[interpolant], rhw, interpolate(xxxx, Dv[interpolant], rhw,
primitive + OFFSET(Primitive, V[interpolant]), primitive + OFFSET(Primitive, V[interpolant]),
input.Flat, state.perspective, false); input.Flat, !input.NoPerspective, false);
} }
} }
} }
......
...@@ -439,8 +439,6 @@ namespace sw ...@@ -439,8 +439,6 @@ namespace sw
for (int interpolant = 0; interpolant < MAX_INTERFACE_COMPONENTS; interpolant++) for (int interpolant = 0; interpolant < MAX_INTERFACE_COMPONENTS; interpolant++)
{ {
// TODO: fix `perspective` throughout interpolation code to consider NoPerspective-decorated interpolants,
// which were not individually-controllable in the GLES implementation.
// Note: `sprite` mode controls whether to replace this interpolant with the point sprite PointCoord value. // Note: `sprite` mode controls whether to replace this interpolant with the point sprite PointCoord value.
// This was an interesting thing to support for old GL because any texture coordinate could be replaced in this way. // This was an interesting thing to support for old GL because any texture coordinate could be replaced in this way.
// In modern GL and in Vulkan, the [gl_]PointCoord builtin variable to the fragment shader is used instead. // In modern GL and in Vulkan, the [gl_]PointCoord builtin variable to the fragment shader is used instead.
...@@ -450,7 +448,7 @@ namespace sw ...@@ -450,7 +448,7 @@ namespace sw
OFFSET(Primitive, V[interpolant]), OFFSET(Primitive, V[interpolant]),
state.gradient[interpolant].Flat, state.gradient[interpolant].Flat,
false /* is pointcoord */, false /* is pointcoord */,
state.perspective, 0); !state.gradient[interpolant].NoPerspective, 0);
} }
Return(1); Return(1);
......
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