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