From c5e25757221e96ad9d80a64ab8c3b3b715563ea9 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sun, 15 Jan 2017 18:46:04 +0700 Subject: [PATCH] Fixes --- src/Combiner.cpp | 17 ++++++++--------- src/FrameBuffer.cpp | 3 +++ .../GLSL/glsl_CombinerProgramBuilder.cpp | 6 ++++-- .../OpenGLContext/opengl_UnbufferedDrawer.cpp | 7 +------ src/GraphicsDrawer.cpp | 8 +++++--- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Combiner.cpp b/src/Combiner.cpp index b67c0ad8..6187443b 100644 --- a/src/Combiner.cpp +++ b/src/Combiner.cpp @@ -73,19 +73,10 @@ static int aAExpanded[] = void Combiner_Init() { CombinerInfo & cmbInfo = CombinerInfo::get(); cmbInfo.init(); -// InitShaderCombiner(); - if (cmbInfo.getCombinersNumber() == 0) { - cmbInfo.setPolygonMode(OGLRender::rsTexRect); - gDP.otherMode.cycleType = G_CYC_COPY; - cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0)); - gDP.otherMode.cycleType = G_CYC_FILL; - cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE)); - } gDP.otherMode.cycleType = G_CYC_1CYCLE; } void Combiner_Destroy() { -// DestroyShaderCombiner(); CombinerInfo::get().destroy(); } @@ -115,6 +106,14 @@ void CombinerInfo::init() m_combiners.clear(); } + if (m_combiners.empty()) { + setPolygonMode(OGLRender::rsTexRect); + gDP.otherMode.cycleType = G_CYC_COPY; + setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0)); + gDP.otherMode.cycleType = G_CYC_FILL; + setCombine(EncodeCombineMode(0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE)); + } + m_shadowmapProgram.reset(gfxContext.createDepthFogShader()); m_monochromeProgram.reset(gfxContext.createMonochromeShader()); m_texrectCopyProgram.reset(gfxContext.createTexrectCopyShader()); diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 4b0e3ec0..2b8b9b26 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -966,6 +966,7 @@ void FrameBufferList::renderBuffer(u32 _address) blitParams.dstWidth = wnd.getScreenWidth(); blitParams.dstHeight = wnd.getScreenHeight() + wnd.getHeightOffset(); blitParams.filter = filter; + blitParams.mask = graphics::blitMask::COLOR_BUFFER; blitParams.tex[0] = pBufferTexture; blitParams.combiner = CombinerInfo::get().getTexrectCopyProgram(); blitParams.readBuffer = readBuffer; @@ -1120,6 +1121,8 @@ bool FrameBuffer_CopyDepthBufferChunk(u32 address) void FrameBuffer_CopyFromRDRAM(u32 _address, bool _bCFB) { + // TODO fix me + return; RDRAMtoColorBuffer::get().copyFromRDRAM(_address, _bCFB); } diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp index cbfc14c6..674caeb1 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp @@ -1674,7 +1674,8 @@ int CombinerProgramBuilder::compileCombiner(const CombinerKey & _key, Combiner & else if (combinedAlphaABD(combine)) m_signExtendAlphaABD->write(ssShader); - m_alphaTest->write(ssShader); + if (g_cycleType < G_CYC_FILL) + m_alphaTest->write(ssShader); ssShader << " color1 = "; nInputs |= _compileCombiner(_color.stage[0], ColorInput, ssShader); @@ -1708,7 +1709,8 @@ int CombinerProgramBuilder::compileCombiner(const CombinerKey & _key, Combiner & ssShader << " lowp vec4 cmbRes = vec4(color2, alpha2);" << std::endl; } else { - ssShader << " if (uCvgXAlpha != 0 && alpha1 < 0.125) discard;" << std::endl; + if (g_cycleType < G_CYC_FILL) + ssShader << " if (uCvgXAlpha != 0 && alpha1 < 0.125) discard;" << std::endl; ssShader << " lowp vec4 cmbRes = vec4(color1, alpha1);" << std::endl; } diff --git a/src/Graphics/OpenGLContext/opengl_UnbufferedDrawer.cpp b/src/Graphics/OpenGLContext/opengl_UnbufferedDrawer.cpp index 40638b8a..c0f2c803 100644 --- a/src/Graphics/OpenGLContext/opengl_UnbufferedDrawer.cpp +++ b/src/Graphics/OpenGLContext/opengl_UnbufferedDrawer.cpp @@ -82,7 +82,6 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame } m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false); - m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, false); m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false); m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false); @@ -103,10 +102,7 @@ void UnbufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _ glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), ptr); } - { - m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, true); - glVertexAttrib4fv(rectAttrib::color, _params.rectColor.data()); - } + glVertexAttrib4fv(rectAttrib::color, _params.rectColor.data()); if (_params.combiner->usesTile(0)) { m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true); @@ -154,7 +150,6 @@ void UnbufferedDrawer::drawLine(f32 _width, SPVertex * _vertices) m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false); m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false); - m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, false); m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false); m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false); diff --git a/src/GraphicsDrawer.cpp b/src/GraphicsDrawer.cpp index 8bd12421..7e030d28 100644 --- a/src/GraphicsDrawer.cpp +++ b/src/GraphicsDrawer.cpp @@ -534,8 +534,6 @@ void GraphicsDrawer::_updateTextures() const void GraphicsDrawer::_updateStates(DrawingState _drawingState) const { -// DisplayWindow & ogl = DisplayWindow::get(); - CombinerInfo & cmbInfo = CombinerInfo::get(); cmbInfo.setPolygonMode(_drawingState); cmbInfo.update(); @@ -881,7 +879,7 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pC Context::DrawRectParameters rectParams; rectParams.mode = drawmode::TRIANGLE_STRIP; if (gDP.otherMode.cycleType == G_CYC_FILL) - std::copy_n(_pColor, sizeof(_pColor[0]) * 4, rectParams.rectColor.data()); + std::copy_n(_pColor, 4, rectParams.rectColor.begin()); else rectParams.rectColor.fill(0.0f); rectParams.verticesCount = 4; @@ -1179,6 +1177,8 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params) if (texParams.wrapS.isValid() || texParams.wrapT.isValid()) { texParams.handle = ObjectHandle(cache.current[t]->glName); + texParams.target = cache.current[t]->frameBufferTexture == CachedTexture::fbMultiSample ? + target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D; texParams.textureUnitIndex = textureIndices::Tex[t]; gfxContext.setTextureParameters(texParams); } @@ -1193,6 +1193,8 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params) if (gDP.otherMode.cycleType == G_CYC_COPY) { Context::TexParameters texParams; texParams.handle = ObjectHandle(cache.current[0]->glName); + texParams.target = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ? + target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D; texParams.textureUnitIndex = textureIndices::Tex[0]; texParams.minFilter = textureParameters::FILTER_NEAREST; texParams.magFilter = textureParameters::FILTER_NEAREST;