From c141e94fe9b433282c9a9f6527d0eef52f8448d6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 24 Aug 2013 10:20:07 -0700 Subject: [PATCH] Use gstate.* accessors in a few more places. --- GPU/GLES/Framebuffer.cpp | 2 +- GPU/GLES/GLES_GPU.cpp | 2 +- GPU/GLES/Spline.cpp | 2 +- GPU/GLES/StateMapping.cpp | 2 +- GPU/GLES/TextureCache.cpp | 4 ++-- GPU/GLES/TransformPipeline.cpp | 15 ++++++++------- GPU/GLES/TransformPipeline.h | 2 +- GPU/GPUState.h | 1 + GPU/Software/SoftGpu.cpp | 2 +- GPU/Software/TransformUnit.cpp | 4 ++-- GPU/Software/TransformUnit.h | 2 +- 11 files changed, 20 insertions(+), 18 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 8af1994c49..6d7f7a8e02 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -475,7 +475,7 @@ void FramebufferManager::SetRenderFrameBuffer() { // As there are no clear "framebuffer width" and "framebuffer height" registers, // we need to infer the size of the current framebuffer somehow. Let's try the viewport. - GEBufferFormat fmt = static_cast(gstate.framebufpixformat & 3); + GEBufferFormat fmt = gstate.FrameBufFormat(); int drawing_width, drawing_height; GuessDrawingSize(drawing_width, drawing_height); diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 2f9391eecb..b9b73cd8a6 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -729,7 +729,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { int sp_vcount = (data >> 8) & 0xFF; int sp_utype = (data >> 16) & 0x3; int sp_vtype = (data >> 18) & 0x3; - int patchPrim = gstate.patchprimitive & 3; + GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); transformDraw_.SubmitSpline(control_points, indices, sp_ucount, sp_vcount, sp_utype, sp_vtype, patchPrim, gstate.vertType); } break; diff --git a/GPU/GLES/Spline.cpp b/GPU/GLES/Spline.cpp index 83c1614072..9e033078d7 100644 --- a/GPU/GLES/Spline.cpp +++ b/GPU/GLES/Spline.cpp @@ -92,7 +92,7 @@ void CopyTriangle(u8 *&dest, u8 *v1, u8 *v2, u8 * v3, int vertexSize) { dest += vertexSize; } -void TransformDrawEngine::SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, u32 prim_type, u32 vertex_type) +void TransformDrawEngine::SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertex_type) { Flush(); diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 54ec9358eb..37ddbe6bfc 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -330,7 +330,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { renderHeightFactor = renderHeight / 272.0f; } - bool throughmode = (gstate.vertType & GE_VTYPE_THROUGH_MASK) != 0; + bool throughmode = gstate.isModeThrough(); // Scissor int scissorX1 = gstate.getScissorX1(); diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 3a7b55ab4c..1f10637a1d 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -550,8 +550,8 @@ static const GLuint MagFiltGL[2] = { void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) { int minFilt = gstate.texfilter & 0x7; int magFilt = (gstate.texfilter>>8) & 1; - bool sClamp = gstate.texwrap & 1; - bool tClamp = (gstate.texwrap>>8) & 1; + bool sClamp = gstate.isTexCoordClampedS(); + bool tClamp = gstate.isTexCoordClampedT(); bool noMip = (gstate.texlevel & 0xFFFFFF) == 0x000001 || (gstate.texlevel & 0xFFFFFF) == 0x100001 ; // Fix texlevel at 0 diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index cac49d7f9d..de3e423aca 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -150,7 +150,7 @@ private: }; Lighter::Lighter() { - doShadeMapping_ = (gstate.texmapmode & 0x3) == 2; + doShadeMapping_ = gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP; materialEmissive.GetFromRGB(gstate.materialemissive); materialEmissive.a = 0.0f; globalAmbient.GetFromRGB(gstate.ambientcolor); @@ -677,16 +677,17 @@ void TransformDrawEngine::SoftwareTransformAndDraw( ((clearColor & 0xFF0000) >> 16) / 255.0f, ((clearColor & 0xFF000000) >> 24) / 255.0f, }; - int target = 0; - if ((gstate.clearmode >> 8) & 3) target |= GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - if ((gstate.clearmode >> 10) & 1) target |= GL_DEPTH_BUFFER_BIT; - bool colorMask = (gstate.clearmode >> 8) & 1; - bool alphaMask = (gstate.clearmode >> 9) & 1; + bool colorMask = gstate.isClearModeColorMask(); + bool alphaMask = gstate.isClearModeAlphaMask(); glstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask); glstate.stencilTest.set(false); glstate.scissorTest.set(false); - bool depthMask = (gstate.clearmode >> 10) & 1; + bool depthMask = gstate.isClearModeDepthMask(); + + int target = 0; + if (colorMask || alphaMask) target |= GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; + if (depthMask) target |= GL_DEPTH_BUFFER_BIT; glClearColor(col[0], col[1], col[2], col[3]); #ifdef USING_GLES2 diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 7fea4f640d..f80c25bf2c 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -98,7 +98,7 @@ public: virtual ~TransformDrawEngine(); void SubmitPrim(void *verts, void *inds, int prim, int vertexCount, u32 vertexType, int forceIndexType, int *bytesRead); void DrawBezier(int ucount, int vcount); - void SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, u32 prim_type, u32 vertex_type); + void SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertex_type); void DecodeVerts(); void SetShaderManager(ShaderManager *shaderManager) { diff --git a/GPU/GPUState.h b/GPU/GPUState.h index f63424d31a..4d5cee44d1 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -225,6 +225,7 @@ struct GPUgstate bool isClearModeDepthWriteEnabled() const { return (clearmode&0x400) != 0; } bool isClearModeColorMask() const { return (clearmode&0x100) != 0; } bool isClearModeAlphaMask() const { return (clearmode&0x200) != 0; } + bool isClearModeDepthMask() const { return (clearmode&0x400) != 0; } u32 getClearModeColorMask() const { return ((clearmode&0x100) ? 0xFFFFFF : 0) | ((clearmode&0x200) ? 0xFF000000 : 0); } // TODO: Different convention than getColorMask, confusing! // Blend diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 756fbad877..a3ff3945d5 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -363,7 +363,7 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff) break; } - TransformUnit::SubmitSpline(control_points, indices, sp_ucount, sp_vcount, sp_utype, sp_vtype, gstate.patchprimitive&3, gstate.vertType); + TransformUnit::SubmitSpline(control_points, indices, sp_ucount, sp_vcount, sp_utype, sp_vtype, gstate.getPatchPrimitiveType(), gstate.vertType); DEBUG_LOG(G3D,"DL DRAW SPLINE: %i x %i, %i x %i", sp_ucount, sp_vcount, sp_utype, sp_vtype); } break; diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index b76d8fc10c..1de4c23617 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -102,7 +102,7 @@ static VertexData ReadVertex(VertexReader& vreader) float pos[3]; vreader.ReadPos(pos); - if (!gstate.isModeClear() && gstate.textureMapEnable && vreader.hasUV()) { + if (!gstate.isModeClear() && gstate.isTextureMapEnabled() && vreader.hasUV()) { float uv[2]; vreader.ReadUV(uv); vertex.texturecoords = Vec2(uv[0], uv[1]); @@ -186,7 +186,7 @@ struct SplinePatch { int type; }; -void TransformUnit::SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, u32 prim_type, u32 vertex_type) +void TransformUnit::SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertex_type) { VertexDecoder vdecoder; vdecoder.SetVertexType(vertex_type); diff --git a/GPU/Software/TransformUnit.h b/GPU/Software/TransformUnit.h index 32ee05ee40..b36cfb49c0 100644 --- a/GPU/Software/TransformUnit.h +++ b/GPU/Software/TransformUnit.h @@ -115,6 +115,6 @@ public: static DrawingCoords ScreenToDrawing(const ScreenCoords& coords); static ScreenCoords DrawingToScreen(const DrawingCoords& coords); - static void SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, u32 prim_type, u32 vertex_type); + static void SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertex_type); static void SubmitPrimitive(void* vertices, void* indices, u32 prim_type, int vertex_count, u32 vertex_type); };