123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- #include "Common/CommonTypes.h"
- #include "Core/ConfigManager.h"
- #include "Core/HW/Memmap.h"
- #include "VideoCommon/BPFunctions.h"
- #include "VideoCommon/RenderBase.h"
- #include "VideoCommon/TextureCacheBase.h"
- #include "VideoCommon/VertexManagerBase.h"
- #include "VideoCommon/VertexShaderManager.h"
- #include "VideoCommon/VideoConfig.h"
- namespace BPFunctions
- {
- void FlushPipeline()
- {
- VertexManager::Flush();
- }
- void SetGenerationMode()
- {
- g_renderer->SetGenerationMode();
- }
- void SetScissor()
- {
-
-
- const int xoff = bpmem.scissorOffset.x * 2;
- const int yoff = bpmem.scissorOffset.y * 2;
- EFBRectangle rc (bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff,
- bpmem.scissorBR.x - xoff + 1, bpmem.scissorBR.y - yoff + 1);
- if (rc.left < 0) rc.left = 0;
- if (rc.top < 0) rc.top = 0;
- if (rc.right > EFB_WIDTH) rc.right = EFB_WIDTH;
- if (rc.bottom > EFB_HEIGHT) rc.bottom = EFB_HEIGHT;
- if (rc.left > rc.right) rc.right = rc.left;
- if (rc.top > rc.bottom) rc.bottom = rc.top;
- g_renderer->SetScissorRect(rc);
- }
- void SetDepthMode()
- {
- g_renderer->SetDepthMode();
- }
- void SetBlendMode()
- {
- g_renderer->SetBlendMode(false);
- }
- void SetDitherMode()
- {
- g_renderer->SetDitherMode();
- }
- void SetLogicOpMode()
- {
- g_renderer->SetLogicOpMode();
- }
- void SetColorMask()
- {
- g_renderer->SetColorMask();
- }
- void CopyEFB(u32 dstAddr, const EFBRectangle& srcRect,
- unsigned int dstFormat, PEControl::PixelFormat srcFormat,
- bool isIntensity, bool scaleByHalf)
- {
-
- TextureCache::CopyRenderTargetToTexture(dstAddr, dstFormat, srcFormat,
- srcRect, isIntensity, scaleByHalf);
- }
- void ClearScreen(const EFBRectangle &rc)
- {
- bool colorEnable = (bpmem.blendmode.colorupdate != 0);
- bool alphaEnable = (bpmem.blendmode.alphaupdate != 0);
- bool zEnable = (bpmem.zmode.updateenable != 0);
- auto pixel_format = bpmem.zcontrol.pixel_format;
-
- if (pixel_format == PEControl::RGB8_Z24 ||
- pixel_format == PEControl::RGB565_Z16 ||
- pixel_format == PEControl::Z24)
- {
- alphaEnable = false;
- }
- if (colorEnable || alphaEnable || zEnable)
- {
- u32 color = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
- u32 z = bpmem.clearZValue;
-
- if (pixel_format == PEControl::RGBA6_Z24)
- {
- color = RGBA8ToRGBA6ToRGBA8(color);
- }
- else if (pixel_format == PEControl::RGB565_Z16)
- {
- color = RGBA8ToRGB565ToRGBA8(color);
- z = Z24ToZ16ToZ24(z);
- }
- g_renderer->ClearScreen(rc, colorEnable, alphaEnable, zEnable, color, z);
- }
- }
- void OnPixelFormatChange()
- {
- int convtype = -1;
-
-
-
-
- if (!g_ActiveConfig.bEFBEmulateFormatChanges)
- return;
- auto old_format = Renderer::GetPrevPixelFormat();
- auto new_format = bpmem.zcontrol.pixel_format;
-
- if (new_format == old_format || old_format == PEControl::INVALID_FMT)
- goto skip;
-
- switch (old_format)
- {
- case PEControl::RGB8_Z24:
- case PEControl::Z24:
-
- if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
- goto skip;
- if (new_format == PEControl::RGBA6_Z24)
- convtype = 0;
- else if (new_format == PEControl::RGB565_Z16)
- convtype = 1;
- break;
- case PEControl::RGBA6_Z24:
- if (new_format == PEControl::RGB8_Z24 ||
- new_format == PEControl::Z24)
- convtype = 2;
- else if (new_format == PEControl::RGB565_Z16)
- convtype = 3;
- break;
- case PEControl::RGB565_Z16:
- if (new_format == PEControl::RGB8_Z24 ||
- new_format == PEControl::Z24)
- convtype = 4;
- else if (new_format == PEControl::RGBA6_Z24)
- convtype = 5;
- break;
- default:
- break;
- }
- if (convtype == -1)
- {
- ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d\n", static_cast<int>(old_format), static_cast<int>(new_format));
- goto skip;
- }
- g_renderer->ReinterpretPixelData(convtype);
- skip:
- DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format), static_cast<int>(bpmem.zcontrol.zformat));
- Renderer::StorePixelFormat(new_format);
- }
- void SetInterlacingMode(const BPCmd &bp)
- {
-
- switch (bp.address)
- {
- case BPMEM_FIELDMODE:
- {
-
-
- const char *action[] = { "don't adjust", "adjust" };
- DEBUG_LOG(VIDEO, "BPMEM_FIELDMODE texLOD:%s lineaspect:%s",
- action[bpmem.fieldmode.texLOD],
- action[bpmem.lineptwidth.lineaspect]);
- }
- break;
- case BPMEM_FIELDMASK:
- {
-
- const char *action[] = { "skip", "write" };
- DEBUG_LOG(VIDEO, "BPMEM_FIELDMASK even:%s odd:%s",
- action[bpmem.fieldmask.even], action[bpmem.fieldmask.odd]);
- }
- break;
- default:
- ERROR_LOG(VIDEO, "SetInterlacingMode default");
- break;
- }
- }
- };
|