Commit 235781d1 by Nicolas Capens

Implement support for wide lines.

Bug 18962347 Change-Id: I673610bfd50bc0e09aedd764336c7e10cfa11e08 Reviewed-on: https://swiftshader-review.googlesource.com/1831Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent eafa0222
......@@ -591,6 +591,7 @@ bool Context::isDitherEnabled() const
void Context::setLineWidth(GLfloat width)
{
mState.lineWidth = width;
device->setLineWidth(clamp(width, ALIASED_LINE_WIDTH_RANGE_MIN, ALIASED_LINE_WIDTH_RANGE_MAX));
}
void Context::setGenerateMipmapHint(GLenum hint)
......
......@@ -94,7 +94,7 @@ const GLenum compressedTextureFormats[] =
const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
const float ALIASED_LINE_WIDTH_RANGE_MAX = 128.0f;
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;
const float ALIASED_POINT_SIZE_RANGE_MAX = 8192.0f;
const float MAX_TEXTURE_MAX_ANISOTROPY = 16.0f;
......
......@@ -68,7 +68,6 @@ namespace gl
setClipFlags(0);
setPointSize(1.0f);
setPointSizeMin(0.125f);
setPointSpriteEnable(false);
setPointSizeMax(8192.0f);
setColorWriteMask(0, 0x0000000F);
setBlendOperation(BLENDOP_ADD);
......
......@@ -626,6 +626,7 @@ void Context::setTexture2D(bool enable)
void Context::setLineWidth(GLfloat width)
{
mState.lineWidth = width;
device->setLineWidth(clamp(width, ALIASED_LINE_WIDTH_RANGE_MIN, ALIASED_LINE_WIDTH_RANGE_MAX));
}
void Context::setGenerateMipmapHint(GLenum hint)
......
......@@ -68,7 +68,6 @@ namespace es1
setClipFlags(0);
setPointSize(1.0f);
setPointSizeMin(0.125f);
setPointSpriteEnable(false);
setPointSizeMax(8192.0f);
setColorWriteMask(0, 0x0000000F);
setBlendOperation(BLENDOP_ADD);
......
......@@ -593,6 +593,7 @@ bool Context::isDitherEnabled() const
void Context::setLineWidth(GLfloat width)
{
mState.lineWidth = width;
device->setLineWidth(clamp(width, ALIASED_LINE_WIDTH_RANGE_MIN, ALIASED_LINE_WIDTH_RANGE_MAX));
}
void Context::setGenerateMipmapHint(GLenum hint)
......
......@@ -68,7 +68,6 @@ namespace es2
setClipFlags(0);
setPointSize(1.0f);
setPointSizeMin(0.125f);
setPointSpriteEnable(false);
setPointSizeMax(8192.0f);
setColorWriteMask(0, 0x0000000F);
setBlendOperation(BLENDOP_ADD);
......
......@@ -491,6 +491,7 @@ bool Context::isDitherEnabled() const
void Context::setLineWidth(GLfloat width)
{
mState.lineWidth = width;
device->setLineWidth(clamp(width, ALIASED_LINE_WIDTH_RANGE_MIN, ALIASED_LINE_WIDTH_RANGE_MAX));
}
void Context::setGenerateMipmapHint(GLenum hint)
......
......@@ -68,7 +68,6 @@ namespace es2
setClipFlags(0);
setPointSize(1.0f);
setPointSizeMin(0.125f);
setPointSpriteEnable(false);
setPointSizeMax(8192.0f);
setColorWriteMask(0, 0x0000000F);
setBlendOperation(BLENDOP_ADD);
......
......@@ -288,6 +288,7 @@ namespace sw
pointSpriteEnable = false;
pointScaleEnable = false;
lineWidth = 1.0f;
writeSRGB = false;
sampleMask = 0xFFFFFFFF;
......
......@@ -472,6 +472,7 @@ namespace sw
bool pointSpriteEnable;
bool pointScaleEnable;
float lineWidth;
int colorWriteMask[4]; // RGBA
bool writeSRGB;
......
......@@ -220,6 +220,10 @@ namespace sw
sync->lock(sw::PRIVATE);
Routine *vertexRoutine;
Routine *setupRoutine;
Routine *pixelRoutine;
if(update || oldMultiSampleMask != context->multiSampleMask)
{
vertexState = VertexProcessor::update();
......@@ -233,6 +237,8 @@ namespace sw
int batch = batchSize / ms;
int (*setupPrimitives)(Renderer *renderer, int batch, int count);
if(context->isDrawTriangle())
{
switch(context->fillMode)
......@@ -438,6 +444,8 @@ namespace sw
data->point = point;
}
data->lineWidth = context->lineWidth;
data->factor = factor;
if(pixelState.transparencyAntialiasing == TRANSPARENCY_ALPHA_TO_COVERAGE)
......@@ -1545,6 +1553,8 @@ namespace sw
const SetupProcessor::State &state = draw.setupState;
const DrawData &data = *draw.data;
float lineWidth = data.lineWidth;
Vertex &v0 = triangle.v0;
Vertex &v1 = triangle.v1;
......@@ -1579,7 +1589,7 @@ namespace sw
P[2] = P1;
P[3] = P0;
float scale = 0.5f / sqrt(dx*dx + dy*dy);
float scale = lineWidth * 0.5f / sqrt(dx*dx + dy*dy);
dx *= scale;
dy *= scale;
......@@ -1641,11 +1651,11 @@ namespace sw
P[6] = P1;
P[7] = P1;
float dx0 = 0.5f * P0.w / W;
float dy0 = 0.5f * P0.w / H;
float dx0 = lineWidth * 0.5f * P0.w / W;
float dy0 = lineWidth * 0.5f * P0.w / H;
float dx1 = 0.5f * P1.w / W;
float dy1 = 0.5f * P1.w / H;
float dx1 = lineWidth * 0.5f * P1.w / W;
float dy1 = lineWidth * 0.5f * P1.w / H;
P[0].x += -dx0;
C[0] = computeClipFlags(P[0], data);
......@@ -2193,6 +2203,11 @@ namespace sw
context->setPointScaleEnable(pointScaleEnable);
}
void Renderer::setLineWidth(float width)
{
context->lineWidth = width;
}
void Renderer::setDepthBias(float bias)
{
depthBias = bias;
......
......@@ -111,6 +111,7 @@ namespace sw
PS ps;
VertexProcessor::PointSprite point;
float lineWidth;
PixelProcessor::Stencil stencil[2]; // clockwise, counterclockwise
PixelProcessor::Stencil stencilCCW;
......@@ -293,6 +294,7 @@ namespace sw
virtual void setPointSpriteEnable(bool pointSpriteEnable);
virtual void setPointScaleEnable(bool pointScaleEnable);
virtual void setLineWidth(float width);
virtual void setDepthBias(float bias);
virtual void setSlopeDepthBias(float slopeBias);
......@@ -419,11 +421,6 @@ namespace sw
VertexProcessor::State vertexState;
SetupProcessor::State setupState;
PixelProcessor::State pixelState;
int (*setupPrimitives)(Renderer *renderer, int batch, int count);
Routine *vertexRoutine;
Routine *setupRoutine;
Routine *pixelRoutine;
Blitter blitter;
};
......
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