mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
gpu: Add support for scissor rectangle
This commit is contained in:
parent
bef3ef7fac
commit
cf458dba60
6 changed files with 27 additions and 12 deletions
|
@ -109,6 +109,8 @@ static const u8 flushOnChangedBeforeCommandList[] = {
|
|||
GE_CMD_TEXMODE,
|
||||
GE_CMD_TEXFORMAT,
|
||||
GE_CMD_TEXWRAP,
|
||||
GE_CMD_SCISSOR1,
|
||||
GE_CMD_SCISSOR2,
|
||||
GE_CMD_ZTESTENABLE,
|
||||
GE_CMD_ZWRITEDISABLE,
|
||||
GE_CMD_STENCILTESTENABLE,
|
||||
|
|
|
@ -273,10 +273,6 @@ void FramebufferManager::SetRenderFrameBuffer() {
|
|||
u32 z_address = (gstate.zbptr & 0xFFE000) | ((gstate.zbwidth & 0xFF0000) << 8);
|
||||
int z_stride = gstate.zbwidth & 0x3C0;
|
||||
|
||||
// We guess that the viewport size during the first draw call is an appropriate
|
||||
// size for a render target.
|
||||
//UpdateViewportAndProjection();
|
||||
|
||||
// Yeah this is not completely right. but it'll do for now.
|
||||
//int drawing_width = ((gstate.region2) & 0x3FF) + 1;
|
||||
//int drawing_height = ((gstate.region2 >> 10) & 0x3FF) + 1;
|
||||
|
|
|
@ -185,6 +185,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
|
|||
// Set Dither
|
||||
glstate.dither.set(gstate.isDitherEnabled());
|
||||
|
||||
|
||||
// Set ColorMask/Stencil/Depth
|
||||
if (gstate.isModeClear()) {
|
||||
bool colorMask = (gstate.clearmode >> 8) & 1;
|
||||
|
@ -230,9 +231,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
|
|||
glstate.stencilTest.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformDrawEngine::UpdateViewportAndProjection() {
|
||||
float renderWidthFactor, renderHeightFactor;
|
||||
float renderWidth, renderHeight;
|
||||
float renderX, renderY;
|
||||
|
@ -254,8 +253,24 @@ void TransformDrawEngine::UpdateViewportAndProjection() {
|
|||
|
||||
bool throughmode = (gstate.vertType & GE_VTYPE_THROUGH_MASK) != 0;
|
||||
|
||||
// We can probably use these to simply set scissors? Maybe we need to offset by regionX1/Y1
|
||||
|
||||
// Scissor
|
||||
int scissorX1 = gstate.scissor1 & 0x3FF;
|
||||
int scissorY1 = (gstate.scissor1 >> 10) & 0x3FF;
|
||||
int scissorX2 = gstate.scissor2 & 0x3FF;
|
||||
int scissorY2 = (gstate.scissor2 >> 10) & 0x3FF;
|
||||
|
||||
// This is a bit of a hack as the render buffer isn't always that size
|
||||
if (scissorX1 == 0 && scissorY1 == 0 && scissorX2 == 480 && scissorY2 == 272) {
|
||||
glstate.scissorTest.disable();
|
||||
} else {
|
||||
glstate.scissorTest.enable();
|
||||
glstate.scissorRect.set(
|
||||
renderX + scissorX1 * renderWidthFactor,
|
||||
renderY + renderHeight - (scissorY2 * renderHeightFactor),
|
||||
(scissorX2 - scissorX1) * renderWidthFactor,
|
||||
(scissorY2 - scissorY1) * renderHeightFactor);
|
||||
}
|
||||
|
||||
/*
|
||||
int regionX1 = gstate.region1 & 0x3FF;
|
||||
int regionY1 = (gstate.region1 >> 10) & 0x3FF;
|
||||
|
@ -272,7 +287,11 @@ void TransformDrawEngine::UpdateViewportAndProjection() {
|
|||
|
||||
if (throughmode) {
|
||||
// No viewport transform here. Let's experiment with using region.
|
||||
glstate.viewport.set(renderX + (0 + regionX1) * renderWidthFactor, renderY + (0 - regionY1) * renderHeightFactor, (regionX2 - regionX1) * renderWidthFactor, (regionY2 - regionY1) * renderHeightFactor);
|
||||
glstate.viewport.set(
|
||||
renderX + (0 + regionX1) * renderWidthFactor,
|
||||
renderY + (0 - regionY1) * renderHeightFactor,
|
||||
(regionX2 - regionX1) * renderWidthFactor,
|
||||
(regionY2 - regionY1) * renderHeightFactor);
|
||||
glstate.depthRange.set(0.0f, 1.0f);
|
||||
} else {
|
||||
// These we can turn into a glViewport call, offset by offsetX and offsetY. Math after.
|
||||
|
|
|
@ -937,7 +937,6 @@ void TransformDrawEngine::Flush() {
|
|||
|
||||
int prim = prevPrim_;
|
||||
ApplyDrawState(prim);
|
||||
UpdateViewportAndProjection();
|
||||
|
||||
LinkedShader *program = shaderManager_->ApplyShader(prim);
|
||||
|
||||
|
|
|
@ -120,7 +120,6 @@ public:
|
|||
private:
|
||||
void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex);
|
||||
void ApplyDrawState(int prim);
|
||||
void UpdateViewportAndProjection();
|
||||
|
||||
// drawcall ID
|
||||
u32 ComputeFastDCID();
|
||||
|
|
2
native
2
native
|
@ -1 +1 @@
|
|||
Subproject commit b9486d43e999d5de403e36cd981842fa575a5488
|
||||
Subproject commit 21a7ee80fb2f31bfff1a739bce80ac8e5047952b
|
Loading…
Add table
Reference in a new issue