mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
D3D11: Stencil and scissor work
This commit is contained in:
parent
cb407a4019
commit
3b12ac5f05
3 changed files with 40 additions and 26 deletions
|
@ -105,7 +105,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
|||
float fogcoef_stencil[3] = {
|
||||
getFloat24(gstate.fog1),
|
||||
getFloat24(gstate.fog2),
|
||||
(float)gstate.getStencilTestRef()
|
||||
(float)gstate.getStencilTestRef()/255.0f
|
||||
};
|
||||
if (my_isinf(fogcoef_stencil[1])) {
|
||||
// not really sure what a sensible value might be.
|
||||
|
|
|
@ -202,12 +202,14 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
if (ApplyShaderBlending()) {
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Until next time, force it off.
|
||||
ResetShaderBlending();
|
||||
gstate_c.allowShaderBlend = false;
|
||||
}
|
||||
} else if (blendState.resetShaderBlending) {
|
||||
}
|
||||
else if (blendState.resetShaderBlending) {
|
||||
ResetShaderBlending();
|
||||
}
|
||||
|
||||
|
@ -226,7 +228,8 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
if (blendState.useBlendColor) {
|
||||
dynState.blendColor = blendState.blendColor;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
key.blend.blendEnable = false;
|
||||
dynState.useBlendColor = false;
|
||||
}
|
||||
|
@ -263,17 +266,20 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
// We override this value in the pipeline from software transform for clear rectangles.
|
||||
dynState.stencilRef = 0xFF;
|
||||
key.depthStencil.stencilWriteMask = 0xFF;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
key.depthStencil.stencilTestEnable = false;
|
||||
dynState.useStencil = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) {
|
||||
// Logic Ops
|
||||
if (gstate.isLogicOpEnabled() && gstate.getLogicOp() != GE_LOGIC_COPY) {
|
||||
key.blend.logicOpEnable = true;
|
||||
// key.blendKey.logicOp = logicOps[gstate.getLogicOp()];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
key.blend.logicOpEnable = false;
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +296,8 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
if (gstate.isDepthWriteEnabled()) {
|
||||
framebufferManager_->SetDepthUpdated();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
key.depthStencil.depthTestEnable = false;
|
||||
key.depthStencil.depthWriteEnable = false;
|
||||
key.depthStencil.depthCompareOp = D3D11_COMPARISON_ALWAYS;
|
||||
|
@ -320,7 +327,8 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
// Let's not write to alpha if stencil isn't enabled.
|
||||
if (!gstate.isStencilTestEnabled()) {
|
||||
amask = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If the stencil type is set to KEEP, we shouldn't write to the stencil/alpha channel.
|
||||
if (ReplaceAlphaWithStencilType() == STENCIL_VALUE_KEEP) {
|
||||
amask = false;
|
||||
|
@ -343,7 +351,8 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
key.depthStencil.stencilWriteMask = stencilState.writeMask;
|
||||
dynState.useStencil = true;
|
||||
dynState.stencilRef = stencilState.testRef;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
key.depthStencil.stencilTestEnable = false;
|
||||
dynState.useStencil = false;
|
||||
}
|
||||
|
@ -378,14 +387,21 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
}
|
||||
context_->RSSetViewports(1, &vp);
|
||||
|
||||
/*
|
||||
D3D11_RECT &scissor = dynState.scissor;
|
||||
scissor.left = vpAndScissor.scissorX;
|
||||
scissor.top = vpAndScissor.scissorY;
|
||||
scissor.right = vpAndScissor.scissorX + vpAndScissor.scissorW;
|
||||
scissor.bottom = vpAndScissor.scissorY + vpAndScissor.scissorH;
|
||||
context_->RSSetScissorRects(0, &scissor);
|
||||
*/
|
||||
if (vpAndScissor.scissorEnable) {
|
||||
scissor.left = vpAndScissor.scissorX;
|
||||
scissor.top = vpAndScissor.scissorY;
|
||||
scissor.right = vpAndScissor.scissorX + vpAndScissor.scissorW;
|
||||
scissor.bottom = vpAndScissor.scissorY + vpAndScissor.scissorH;
|
||||
}
|
||||
else {
|
||||
scissor.left = 0;
|
||||
scissor.top = 0;
|
||||
scissor.right = framebufferManager_->GetRenderWidth();
|
||||
scissor.bottom = framebufferManager_->GetRenderHeight();
|
||||
}
|
||||
context_->RSSetScissorRects(1, &scissor);
|
||||
|
||||
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
|
||||
textureCache_->SetTexture();
|
||||
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
|
||||
|
|
|
@ -177,23 +177,17 @@ bool FramebufferManagerD3D11::NotifyStencilUpload(u32 addr, int size, bool skipZ
|
|||
|
||||
shaderManager_->DirtyLastShader();
|
||||
|
||||
DisableState();
|
||||
|
||||
context_->OMSetBlendState(stockD3D11.blendStateDisabledWithColorMask[0x8], nullptr, 0xFFFFFFFF);
|
||||
context_->OMSetDepthStencilState(stockD3D11.depthDisabledStencilWrite, 0xFF);
|
||||
context_->RSSetState(stockD3D11.rasterStateNoCull);
|
||||
|
||||
u16 w = dstBuffer->renderWidth;
|
||||
u16 h = dstBuffer->renderHeight;
|
||||
|
||||
MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->bufferWidth, dstBuffer->bufferHeight);
|
||||
if (dstBuffer->fbo) {
|
||||
draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo);
|
||||
} else {
|
||||
// something is wrong...
|
||||
}
|
||||
D3D11_VIEWPORT vp{ 0.0f, 0.0f, (float)w, (float)h, 0.0f, 1.0f };
|
||||
context_->RSSetViewports(1, &vp);
|
||||
|
||||
MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->bufferWidth, dstBuffer->bufferHeight);
|
||||
|
||||
// Zero stencil
|
||||
draw_->Clear(Draw::ClearFlag::STENCIL, 0, 0, 0);
|
||||
|
||||
|
@ -222,6 +216,7 @@ bool FramebufferManagerD3D11::NotifyStencilUpload(u32 addr, int size, bool skipZ
|
|||
shaderManager_->DirtyLastShader();
|
||||
textureCacheD3D11_->ForgetLastTexture();
|
||||
|
||||
context_->OMSetBlendState(stockD3D11.blendStateDisabledWithColorMask[0x8], nullptr, 0xFFFFFFFF);
|
||||
context_->IASetInputLayout(stencilUploadInputLayout_);
|
||||
context_->PSSetShader(stencilUploadPS_, nullptr, 0);
|
||||
context_->VSSetShader(stencilUploadVS_, nullptr, 0);
|
||||
|
@ -229,6 +224,9 @@ bool FramebufferManagerD3D11::NotifyStencilUpload(u32 addr, int size, bool skipZ
|
|||
context_->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
context_->RSSetState(stockD3D11.rasterStateNoCull);
|
||||
context_->IASetVertexBuffers(0, 1, &quadBuffer_, &quadStride_, &quadOffset_);
|
||||
context_->OMSetBlendState(stockD3D11.blendStateDisabledWithColorMask[0x8], nullptr, 0xFFFFFFFF);
|
||||
context_->OMSetDepthStencilState(stockD3D11.depthDisabledStencilWrite, 0xFF);
|
||||
context_->RSSetState(stockD3D11.rasterStateNoCull);
|
||||
|
||||
for (int i = 1; i < values; i += i) {
|
||||
if (!(usedBits & i)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue