Commit 3751c1ed by Nicolas Capens

Support separate depth and stencil buffers.

Bug 27460431 Change-Id: If11e16597b3fdfbfa6f1f2282e287b302b541f63 Reviewed-on: https://swiftshader-review.googlesource.com/4976Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent b02a8ee6
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -425,7 +425,8 @@ namespace gl ...@@ -425,7 +425,8 @@ namespace gl
this->depthStencil = depthStencil; this->depthStencil = depthStencil;
setDepthStencil(depthStencil); setDepthBuffer(depthStencil);
setStencilBuffer(depthStencil);
} }
void Device::setPixelShader(PixelShader *pixelShader) void Device::setPixelShader(PixelShader *pixelShader)
......
...@@ -322,7 +322,8 @@ namespace es1 ...@@ -322,7 +322,8 @@ namespace es1
this->depthStencil = depthStencil; this->depthStencil = depthStencil;
setDepthStencil(depthStencil); setDepthBuffer(depthStencil);
setStencilBuffer(depthStencil);
} }
void Device::setScissorEnable(bool enable) void Device::setScissorEnable(bool enable)
......
...@@ -348,7 +348,8 @@ namespace es2 ...@@ -348,7 +348,8 @@ namespace es2
this->depthStencil = depthStencil; this->depthStencil = depthStencil;
setDepthStencil(depthStencil); setDepthBuffer(depthStencil);
setStencilBuffer(depthStencil);
} }
void Device::setPixelShader(PixelShader *pixelShader) void Device::setPixelShader(PixelShader *pixelShader)
......
...@@ -219,9 +219,10 @@ namespace sw ...@@ -219,9 +219,10 @@ namespace sw
for(int i = 0; i < RENDERTARGETS; ++i) for(int i = 0; i < RENDERTARGETS; ++i)
{ {
renderTarget[i] = 0; renderTarget[i] = nullptr;
} }
depthStencil = 0; depthBuffer = nullptr;
stencilBuffer = nullptr;
stencilEnable = false; stencilEnable = false;
stencilCompareMode = STENCIL_ALWAYS; stencilCompareMode = STENCIL_ALWAYS;
...@@ -519,12 +520,12 @@ namespace sw ...@@ -519,12 +520,12 @@ namespace sw
bool Context::depthBufferActive() bool Context::depthBufferActive()
{ {
return depthStencil && depthBufferEnable; return depthBuffer && depthBufferEnable;
} }
bool Context::stencilActive() bool Context::stencilActive()
{ {
return depthStencil && stencilEnable; return stencilBuffer && stencilEnable;
} }
bool Context::vertexLightingActive() bool Context::vertexLightingActive()
......
...@@ -456,7 +456,8 @@ namespace sw ...@@ -456,7 +456,8 @@ namespace sw
bool textureTransformProject[8]; bool textureTransformProject[8];
Surface *renderTarget[RENDERTARGETS]; Surface *renderTarget[RENDERTARGETS];
Surface *depthStencil; Surface *depthBuffer;
Surface *stencilBuffer;
// Fog // Fog
bool fogEnable; bool fogEnable;
......
...@@ -172,9 +172,14 @@ namespace sw ...@@ -172,9 +172,14 @@ namespace sw
context->renderTarget[index] = renderTarget; context->renderTarget[index] = renderTarget;
} }
void PixelProcessor::setDepthStencil(Surface *depthStencil) void PixelProcessor::setDepthBuffer(Surface *depthBuffer)
{ {
context->depthStencil = depthStencil; context->depthBuffer = depthBuffer;
}
void PixelProcessor::setStencilBuffer(Surface *stencilBuffer)
{
context->stencilBuffer = stencilBuffer;
} }
void PixelProcessor::setTexCoordIndex(unsigned int stage, int texCoordIndex) void PixelProcessor::setTexCoordIndex(unsigned int stage, int texCoordIndex)
...@@ -939,9 +944,9 @@ namespace sw ...@@ -939,9 +944,9 @@ namespace sw
{ {
state.depthTestActive = true; state.depthTestActive = true;
state.depthCompareMode = context->depthCompareMode; state.depthCompareMode = context->depthCompareMode;
state.quadLayoutDepthBuffer = context->depthStencil->getInternalFormat() != FORMAT_D32F_LOCKABLE && state.quadLayoutDepthBuffer = context->depthBuffer->getInternalFormat() != FORMAT_D32F_LOCKABLE &&
context->depthStencil->getInternalFormat() != FORMAT_D32FS8_TEXTURE && context->depthBuffer->getInternalFormat() != FORMAT_D32FS8_TEXTURE &&
context->depthStencil->getInternalFormat() != FORMAT_D32FS8_SHADOW; context->depthBuffer->getInternalFormat() != FORMAT_D32FS8_SHADOW;
} }
state.occlusionEnabled = context->occlusionEnabled; state.occlusionEnabled = context->occlusionEnabled;
......
...@@ -196,7 +196,8 @@ namespace sw ...@@ -196,7 +196,8 @@ namespace sw
virtual void unlockUniformBuffers(); virtual void unlockUniformBuffers();
virtual void setRenderTarget(int index, Surface *renderTarget); virtual void setRenderTarget(int index, Surface *renderTarget);
virtual void setDepthStencil(Surface *depthStencil); virtual void setDepthBuffer(Surface *depthBuffer);
virtual void setStencilBuffer(Surface *stencilBuffer);
virtual void setTexCoordIndex(unsigned int stage, int texCoordIndex); virtual void setTexCoordIndex(unsigned int stage, int texCoordIndex);
virtual void setStageOperation(unsigned int stage, TextureStage::StageOperation stageOperation); virtual void setStageOperation(unsigned int stage, TextureStage::StageOperation stageOperation);
......
...@@ -591,17 +591,21 @@ namespace sw ...@@ -591,17 +591,21 @@ namespace sw
} }
} }
draw->depthStencil = context->depthStencil; draw->depthBuffer = context->depthBuffer;
draw->stencilBuffer = context->stencilBuffer;
if(draw->depthStencil) if(draw->depthBuffer)
{ {
data->depthBuffer = (float*)context->depthStencil->lockInternal(0, 0, q * ms, LOCK_READWRITE, MANAGED); data->depthBuffer = (float*)context->depthBuffer->lockInternal(0, 0, q * ms, LOCK_READWRITE, MANAGED);
data->depthPitchB = context->depthStencil->getInternalPitchB(); data->depthPitchB = context->depthBuffer->getInternalPitchB();
data->depthSliceB = context->depthStencil->getInternalSliceB(); data->depthSliceB = context->depthBuffer->getInternalSliceB();
}
data->stencilBuffer = (unsigned char*)context->depthStencil->lockStencil(q * ms, MANAGED); if(draw->stencilBuffer)
data->stencilPitchB = context->depthStencil->getStencilPitchB(); {
data->stencilSliceB = context->depthStencil->getStencilSliceB(); data->stencilBuffer = (unsigned char*)context->stencilBuffer->lockStencil(q * ms, MANAGED);
data->stencilPitchB = context->stencilBuffer->getStencilPitchB();
data->stencilSliceB = context->stencilBuffer->getStencilSliceB();
} }
} }
...@@ -946,10 +950,14 @@ namespace sw ...@@ -946,10 +950,14 @@ namespace sw
} }
} }
if(draw.depthStencil) if(draw.depthBuffer)
{
draw.depthBuffer->unlockInternal();
}
if(draw.stencilBuffer)
{ {
draw.depthStencil->unlockInternal(); draw.stencilBuffer->unlockStencil();
draw.depthStencil->unlockStencil();
} }
for(int i = 0; i < TOTAL_IMAGE_UNITS; i++) for(int i = 0; i < TOTAL_IMAGE_UNITS; i++)
...@@ -2086,7 +2094,7 @@ namespace sw ...@@ -2086,7 +2094,7 @@ namespace sw
} }
} }
if(context->depthStencil && context->texture[sampler] == context->depthStencil->getResource()) if(context->depthBuffer && context->texture[sampler] == context->depthBuffer->getResource())
{ {
return true; return true;
} }
......
...@@ -219,7 +219,8 @@ namespace sw ...@@ -219,7 +219,8 @@ namespace sw
Resource *vertexStream[VERTEX_ATTRIBUTES]; Resource *vertexStream[VERTEX_ATTRIBUTES];
Resource *indexBuffer; Resource *indexBuffer;
Surface *renderTarget[RENDERTARGETS]; Surface *renderTarget[RENDERTARGETS];
Surface *depthStencil; Surface *depthBuffer;
Surface *stencilBuffer;
Resource *texture[TOTAL_IMAGE_UNITS]; Resource *texture[TOTAL_IMAGE_UNITS];
int vsDirtyConstF; int vsDirtyConstF;
......
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