mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 05:49:34 +00:00
Replace OGLVideo by DisplayWindow
Replace OGLRender by GraphicsDrawer
This commit is contained in:
parent
06749dcf9e
commit
e83c3489a3
|
@ -19,6 +19,7 @@
|
|||
#endif
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
ColorBufferToRDRAM::ColorBufferToRDRAM()
|
||||
: m_FBO(0)
|
||||
|
@ -126,8 +127,8 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
|
|||
if (VI.width == 0 || frameBufferList().getCurrent() == nullptr)
|
||||
return false;
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
const u32 curFrame = ogl.getBuffersSwapCount();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
const u32 curFrame = wnd.getBuffersSwapCount();
|
||||
FrameBuffer * pBuffer = frameBufferList().findBuffer(_startAddress);
|
||||
|
||||
if (pBuffer == nullptr || pBuffer->m_isOBScreen)
|
||||
|
@ -163,23 +164,30 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
|
|||
return false;
|
||||
}
|
||||
|
||||
graphics::ObjectHandle readBuffer;
|
||||
|
||||
if (config.video.multisampling != 0) {
|
||||
m_pCurFrameBuffer->resolveMultisampledTexture();
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_resolveFBO);
|
||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_resolveFBO);
|
||||
readBuffer = graphics::ObjectHandle(m_pCurFrameBuffer->m_resolveFBO);
|
||||
} else {
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_FBO);
|
||||
readBuffer = graphics::ObjectHandle(m_pCurFrameBuffer->m_FBO);
|
||||
}
|
||||
else
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_FBO);
|
||||
|
||||
|
||||
if (m_pCurFrameBuffer->m_scaleX != 1.0f || m_pCurFrameBuffer->m_scaleY != 1.0f) {
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
|
||||
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
|
||||
graphics::ObjectHandle drawBuffer(m_FBO);
|
||||
|
||||
u32 x0 = 0;
|
||||
u32 width, height;
|
||||
if (config.frameBufferEmulation.nativeResFactor == 0) {
|
||||
height = ogl.getHeight();
|
||||
const u32 screenWidth = ogl.getWidth();
|
||||
height = wnd.getHeight();
|
||||
const u32 screenWidth = wnd.getWidth();
|
||||
width = screenWidth;
|
||||
if (ogl.isAdjustScreen()) {
|
||||
width = static_cast<u32>(screenWidth*ogl.getAdjustScale());
|
||||
if (wnd.isAdjustScreen()) {
|
||||
width = static_cast<u32>(screenWidth*wnd.getAdjustScale());
|
||||
x0 = (screenWidth - width) / 2;
|
||||
}
|
||||
}
|
||||
|
@ -189,12 +197,29 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
|
|||
}
|
||||
|
||||
CachedTexture * pInputTexture = frameBufferList().getCurrent()->m_pTexture;
|
||||
ogl.getRender().copyTexturedRect(x0, 0, x0 + width, height,
|
||||
pInputTexture->realWidth, pInputTexture->realHeight, pInputTexture->glName,
|
||||
0, 0, VI.width, VI.height,
|
||||
m_pTexture->realWidth, m_pTexture->realHeight, GL_NEAREST);
|
||||
GraphicsDrawer::BlitOrCopyRectParams blitParams;
|
||||
blitParams.srcX0 = x0;
|
||||
blitParams.srcY0 = 0;
|
||||
blitParams.srcX1 = x0 + width;
|
||||
blitParams.srcY1 = height;
|
||||
blitParams.srcWidth = pInputTexture->realWidth;
|
||||
blitParams.srcHeight = pInputTexture->realHeight;
|
||||
blitParams.dstX0 = 0;
|
||||
blitParams.dstY0 = 0;
|
||||
blitParams.dstX1 = VI.width;
|
||||
blitParams.dstY1 = VI.height;
|
||||
blitParams.dstWidth = m_pTexture->realWidth;
|
||||
blitParams.dstHeight = m_pTexture->realHeight;
|
||||
blitParams.filter = graphics::textureParameters::FILTER_NEAREST;
|
||||
blitParams.tex[0] = pInputTexture;
|
||||
blitParams.combiner = CombinerInfo::get().getTexrectCopyProgram();
|
||||
blitParams.readBuffer = readBuffer;
|
||||
blitParams.drawBuffer = drawBuffer;
|
||||
blitParams.mask = graphics::blitMask::COLOR_BUFFER;
|
||||
wnd.getDrawer().blitOrCopyTexturedRect(blitParams);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
||||
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, graphics::ObjectHandle(m_FBO));
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
||||
}
|
||||
|
||||
m_frameCount = curFrame;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
#ifndef GLES2
|
||||
|
||||
|
@ -142,7 +143,7 @@ void DepthBufferToRDRAM::destroy() {
|
|||
|
||||
bool DepthBufferToRDRAM::_prepareCopy(u32 _address, bool _copyChunk)
|
||||
{
|
||||
const u32 curFrame = video().getBuffersSwapCount();
|
||||
const u32 curFrame = dwnd().getBuffersSwapCount();
|
||||
if (_copyChunk && m_frameCount == curFrame)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
RDRAMtoColorBuffer::RDRAMtoColorBuffer()
|
||||
: m_pCurBuffer(nullptr)
|
||||
|
@ -280,10 +281,12 @@ void RDRAMtoColorBuffer::copyFromRDRAM(u32 _address, bool _bCFB)
|
|||
CombinerInfo::get().updateParameters();
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurBuffer->m_FBO);
|
||||
OGLRender::TexturedRectParams params((float)x0, (float)y0, (float)width, (float)height,
|
||||
|
||||
GraphicsDrawer::TexturedRectParams params((float)x0, (float)y0, (float)width, (float)height,
|
||||
0.0f, 0.0f, width - 1.0f, height - 1.0f, 1.0f, 1.0f,
|
||||
false, true, false, m_pCurBuffer);
|
||||
video().getRender().drawTexturedRect(params);
|
||||
dwnd().getDrawer().drawTexturedRect(params);
|
||||
|
||||
frameBufferList().setCurrentDrawBuffer();
|
||||
|
||||
gSP.textureTile[0] = pTile0;
|
||||
|
|
|
@ -117,12 +117,14 @@ void CombinerInfo::init()
|
|||
|
||||
m_shadowmapProgram.reset(gfxContext.createDepthFogShader());
|
||||
m_monochromeProgram.reset(gfxContext.createMonochromeShader());
|
||||
m_texrectCopyProgram.reset(gfxContext.createTexrectCopyShader());
|
||||
}
|
||||
|
||||
void CombinerInfo::destroy()
|
||||
{
|
||||
m_shadowmapProgram.reset();
|
||||
m_monochromeProgram.reset();
|
||||
m_texrectCopyProgram.reset();
|
||||
|
||||
m_pCurrent = nullptr;
|
||||
if (m_bShaderCacheSupported)
|
||||
|
@ -304,6 +306,11 @@ void CombinerInfo::setMonochromeCombiner()
|
|||
}
|
||||
}
|
||||
|
||||
graphics::ShaderProgram * CombinerInfo::getTexrectCopyProgram()
|
||||
{
|
||||
return m_texrectCopyProgram.get();
|
||||
}
|
||||
|
||||
void CombinerInfo::setPolygonMode(OGLRender::RENDER_STATE _renderState)
|
||||
{
|
||||
switch (_renderState) {
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
|
||||
void setDepthFogCombiner();
|
||||
void setMonochromeCombiner();
|
||||
graphics::ShaderProgram * getTexrectCopyProgram();
|
||||
|
||||
graphics::CombinerProgram * getCurrent() const { return m_pCurrent; }
|
||||
bool isChanged() const {return m_bChanged;}
|
||||
|
@ -166,6 +167,7 @@ private:
|
|||
|
||||
std::unique_ptr<graphics::ShaderProgram> m_shadowmapProgram;
|
||||
std::unique_ptr<graphics::ShaderProgram> m_monochromeProgram;
|
||||
std::unique_ptr<graphics::ShaderProgram> m_texrectCopyProgram;
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
|
@ -13,11 +13,14 @@
|
|||
#include "Debug.h"
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
const GLuint ZlutImageUnit = 0;
|
||||
const GLuint TlutImageUnit = 1;
|
||||
const GLuint depthImageUnit = 2;
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_ulx(0), m_uly(0), m_lrx(0), m_lry(0),
|
||||
m_depthImageFBO(0), m_pDepthImageTexture(nullptr), m_pDepthBufferTexture(nullptr),
|
||||
m_depthRenderbuffer(0), m_depthRenderbufferWidth(0),
|
||||
|
@ -25,7 +28,7 @@ DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_ulx(0), m_uly(0), m_lrx
|
|||
m_pDepthBufferCopyTexture(nullptr), m_copied(false)
|
||||
{
|
||||
m_copyFBO = GLuint(gfxContext.createFramebuffer());
|
||||
if (video().getRender().isImageTexturesSupported() && config.frameBufferEmulation.N64DepthCompare != 0)
|
||||
if (Context::imageTextures && config.frameBufferEmulation.N64DepthCompare != 0)
|
||||
m_depthImageFBO = GLuint(gfxContext.createFramebuffer());
|
||||
}
|
||||
|
||||
|
@ -61,8 +64,7 @@ DepthBuffer::~DepthBuffer()
|
|||
|
||||
void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||
{
|
||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||
if (!video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr)
|
||||
if (!Context::imageTextures || config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr)
|
||||
return;
|
||||
|
||||
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
||||
|
@ -118,9 +120,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
|||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
|
||||
|
||||
|
||||
depthBufferList().clearBuffer(0, 0, VI.width, VI.height);
|
||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||
}
|
||||
|
||||
void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture * _pTexture, bool _multisample)
|
||||
|
@ -135,8 +135,8 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
|
|||
_pTexture->clampHeight = _pBuffer->m_height;
|
||||
} else {
|
||||
if (config.frameBufferEmulation.nativeResFactor == 0) {
|
||||
_pTexture->width = video().getWidth();
|
||||
_pTexture->height = video().getHeight();
|
||||
_pTexture->width = dwnd().getWidth();
|
||||
_pTexture->height = dwnd().getHeight();
|
||||
} else {
|
||||
_pTexture->width = VI.width * config.frameBufferEmulation.nativeResFactor;
|
||||
_pTexture->height = VI.height * config.frameBufferEmulation.nativeResFactor;
|
||||
|
@ -193,8 +193,8 @@ void DepthBuffer::_initDepthBufferRenderbuffer(FrameBuffer * _pBuffer)
|
|||
height = (u32)(_pBuffer->m_pTexture->height);
|
||||
} else {
|
||||
if (config.frameBufferEmulation.nativeResFactor == 0) {
|
||||
m_depthRenderbufferWidth = video().getWidth();
|
||||
height = video().getHeight();
|
||||
m_depthRenderbufferWidth = dwnd().getWidth();
|
||||
height = dwnd().getHeight();
|
||||
} else {
|
||||
m_depthRenderbufferWidth = VI.width * config.frameBufferEmulation.nativeResFactor;
|
||||
height = VI.height * config.frameBufferEmulation.nativeResFactor;
|
||||
|
@ -450,19 +450,19 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry)
|
|||
m_pCurrent->m_uly = _uly;
|
||||
m_pCurrent->m_lrx = _lrx;
|
||||
m_pCurrent->m_lry = _lry;
|
||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||
if (m_pCurrent->m_depthImageFBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
|
||||
|
||||
if (m_pCurrent->m_depthImageFBO == 0 || !Context::imageTextures || config.frameBufferEmulation.N64DepthCompare == 0)
|
||||
return;
|
||||
|
||||
float color[4] = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GLenum(fbTexFormats.depthImageInternalFormat));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageFBO);
|
||||
const u32 cycleType = gDP.otherMode.cycleType;
|
||||
gDP.otherMode.cycleType = G_CYC_FILL;
|
||||
video().getRender().drawRect(_ulx, _uly, _lrx, _lry, color);
|
||||
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
||||
gDP.otherMode.cycleType = cycleType;
|
||||
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GLenum(fbTexFormats.depthImageInternalFormat));
|
||||
frameBufferList().setCurrentDrawBuffer();
|
||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||
}
|
||||
|
||||
void DepthBuffer_Init()
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include <assert.h>
|
||||
#include "Config.h"
|
||||
#include "VI.h"
|
||||
#include "DisplayWindow.h"
|
||||
#include "Graphics/Context.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
void DisplayWindow::start()
|
||||
{
|
||||
_start(); // TODO: process initialization error
|
||||
gfxContext.init();
|
||||
// m_render._initData();
|
||||
m_drawer._initData();
|
||||
m_buffersSwapCount = 0;
|
||||
}
|
||||
|
||||
void DisplayWindow::stop()
|
||||
{
|
||||
// m_render._destroyData();
|
||||
m_drawer._destroyData();
|
||||
gfxContext.destroy();
|
||||
_stop();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ void DisplayWindow::restart()
|
|||
|
||||
void DisplayWindow::swapBuffers()
|
||||
{
|
||||
// m_render.drawOSD();
|
||||
m_drawer.drawOSD();
|
||||
_swapBuffers();
|
||||
gDP.otherMode.l = 0;
|
||||
if ((config.generalEmulation.hacks & hack_doNotResetTLUTmode) == 0)
|
||||
|
@ -52,10 +52,10 @@ bool DisplayWindow::changeWindow()
|
|||
{
|
||||
if (!m_bToggleFullscreen)
|
||||
return false;
|
||||
// m_render._destroyData();
|
||||
m_drawer._destroyData();
|
||||
_changeWindow();
|
||||
updateScale();
|
||||
// m_render._initData();
|
||||
m_drawer._initData();
|
||||
m_bToggleFullscreen = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ bool DisplayWindow::resizeWindow()
|
|||
{
|
||||
if (!m_bResizeWindow)
|
||||
return false;
|
||||
// m_render._destroyData();
|
||||
m_drawer._destroyData();
|
||||
if (!_resizeWindow())
|
||||
_start();
|
||||
updateScale();
|
||||
// m_render._initData();
|
||||
m_drawer._initData();
|
||||
m_bResizeWindow = false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "Types.h"
|
||||
#include "GraphicsDrawer.h"
|
||||
|
||||
class DisplayWindow
|
||||
{
|
||||
|
@ -33,6 +34,8 @@ public:
|
|||
bool isAdjustScreen() const { return m_bAdjustScreen; }
|
||||
bool isResizeWindow() const { return m_bResizeWindow; }
|
||||
|
||||
GraphicsDrawer & getDrawer() { return m_drawer; }
|
||||
|
||||
static DisplayWindow & get();
|
||||
|
||||
protected:
|
||||
|
@ -61,7 +64,7 @@ protected:
|
|||
wchar_t m_strScreenDirectory[PLUGIN_PATH_SIZE];
|
||||
|
||||
private:
|
||||
// OGLRender m_render;
|
||||
GraphicsDrawer m_drawer;
|
||||
|
||||
virtual bool _start() = 0;
|
||||
virtual void _stop() = 0;
|
||||
|
@ -72,3 +75,9 @@ private:
|
|||
virtual void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) = 0;
|
||||
virtual void _readScreen2(void * _dest, int * _width, int * _height, int _front) = 0;
|
||||
};
|
||||
|
||||
inline
|
||||
DisplayWindow & dwnd()
|
||||
{
|
||||
return DisplayWindow::get();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -143,7 +144,7 @@ bool FrameBuffer::isAuxiliary() const
|
|||
|
||||
void FrameBuffer::init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u16 _width, u16 _height, bool _cfb)
|
||||
{
|
||||
OGLVideo & ogl = video();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
m_startAddress = _address;
|
||||
m_endAddress = _endAddress;
|
||||
m_width = _width;
|
||||
|
@ -155,8 +156,8 @@ void FrameBuffer::init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u1
|
|||
} else if (config.frameBufferEmulation.nativeResFactor != 0) {
|
||||
m_scaleX = m_scaleY = static_cast<float>(config.frameBufferEmulation.nativeResFactor);
|
||||
} else {
|
||||
m_scaleX = ogl.getScaleX();
|
||||
m_scaleY = ogl.getScaleY();
|
||||
m_scaleX = wnd.getScaleX();
|
||||
m_scaleY = wnd.getScaleY();
|
||||
}
|
||||
m_cfb = _cfb;
|
||||
m_needHeightCorrection = _width != VI.width && _width != *REG.VI_WIDTH;
|
||||
|
@ -179,7 +180,7 @@ void FrameBuffer::init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u1
|
|||
} else
|
||||
_setAndAttachTexture(m_FBO, m_pTexture, 0, false);
|
||||
|
||||
ogl.getRender().clearColorBuffer(nullptr);
|
||||
wnd.getDrawer().clearColorBuffer(nullptr);
|
||||
}
|
||||
|
||||
void FrameBuffer::reinit(u16 _height)
|
||||
|
@ -254,9 +255,9 @@ void FrameBuffer::copyRdram()
|
|||
bool FrameBuffer::isValid(bool _forceCheck) const
|
||||
{
|
||||
if (!_forceCheck) {
|
||||
if (m_validityChecked == video().getBuffersSwapCount())
|
||||
if (m_validityChecked == dwnd().getBuffersSwapCount())
|
||||
return true; // Already checked
|
||||
m_validityChecked = video().getBuffersSwapCount();
|
||||
m_validityChecked = dwnd().getBuffersSwapCount();
|
||||
}
|
||||
|
||||
const u32 * const pData = (const u32*)RDRAM;
|
||||
|
@ -562,7 +563,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
return;
|
||||
}
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
bool bPrevIsDepth = false;
|
||||
|
||||
if (m_pCurrent != nullptr) {
|
||||
|
@ -596,8 +597,8 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
const u32 endAddress = _address + ((_width * _height) << _size >> 1) - 1;
|
||||
if (m_pCurrent == nullptr || m_pCurrent->m_startAddress != _address || m_pCurrent->m_width != _width)
|
||||
m_pCurrent = findBuffer(_address);
|
||||
const float scaleX = config.frameBufferEmulation.nativeResFactor == 0 ? ogl.getScaleX() : static_cast<float>(config.frameBufferEmulation.nativeResFactor);
|
||||
const float scaleY = config.frameBufferEmulation.nativeResFactor == 0 ? ogl.getScaleY() : scaleX;
|
||||
const float scaleX = config.frameBufferEmulation.nativeResFactor == 0 ? wnd.getScaleX() : static_cast<float>(config.frameBufferEmulation.nativeResFactor);
|
||||
const float scaleY = config.frameBufferEmulation.nativeResFactor == 0 ? wnd.getScaleY() : scaleX;
|
||||
if (m_pCurrent != nullptr) {
|
||||
if ((m_pCurrent->m_startAddress != _address) ||
|
||||
(m_pCurrent->m_width != _width) ||
|
||||
|
@ -618,7 +619,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
if (m_pCurrent->m_size != _size) {
|
||||
f32 fillColor[4];
|
||||
gDPGetFillColor(fillColor);
|
||||
ogl.getRender().clearColorBuffer(fillColor);
|
||||
wnd.getDrawer().clearColorBuffer(fillColor);
|
||||
m_pCurrent->m_size = _size;
|
||||
m_pCurrent->m_pTexture->format = _format;
|
||||
m_pCurrent->m_pTexture->size = _size;
|
||||
|
@ -661,7 +662,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
|||
// N64 games may use partial depth buffer clear for aux buffers
|
||||
// It will not work for GL, so we have to force clear depth buffer for aux buffer
|
||||
const DepthBuffer * pDepth = m_pCurrent->m_pDepthBuffer;
|
||||
ogl.getRender().clearDepthBuffer(pDepth->m_ulx, pDepth->m_uly, pDepth->m_lrx, pDepth->m_lry);
|
||||
wnd.getDrawer().clearDepthBuffer(pDepth->m_ulx, pDepth->m_uly, pDepth->m_lrx, pDepth->m_lry);
|
||||
}
|
||||
|
||||
m_pCurrent->m_isDepthBuffer = _address == gDP.depthImageAddress;
|
||||
|
@ -761,7 +762,7 @@ void FrameBufferList::attachDepthBuffer()
|
|||
#endif // USE_DEPTH_RENDERBUFFER
|
||||
m_pCurrent->m_pDepthBuffer = pDepthBuffer;
|
||||
pDepthBuffer->setDepthAttachment(m_pCurrent->m_FBO, GL_DRAW_FRAMEBUFFER);
|
||||
if (video().getRender().isImageTexturesSupported() && config.frameBufferEmulation.N64DepthCompare != 0)
|
||||
if (graphics::Context::imageTextures && config.frameBufferEmulation.N64DepthCompare != 0)
|
||||
pDepthBuffer->bindDepthImageTexture();
|
||||
} else
|
||||
m_pCurrent->m_pDepthBuffer = nullptr;
|
||||
|
@ -817,8 +818,8 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
if (pBuffer == nullptr)
|
||||
return;
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
OGLRender & render = ogl.getRender();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||
GLint srcY0, srcY1, dstY0, dstY1;
|
||||
GLint X0, X1, Xwidth;
|
||||
GLint Xoffset = 0;
|
||||
|
@ -842,7 +843,7 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
vEnd >>= 1;
|
||||
const u32 vFullHeight = isPAL ? 288 : 240;
|
||||
const u32 vCurrentHeight = vEnd - vStart;
|
||||
const float dstScaleY = (float)ogl.getHeight() / float(vFullHeight);
|
||||
const float dstScaleY = (float)wnd.getHeight() / float(vFullHeight);
|
||||
|
||||
bool isLowerField = false;
|
||||
if (interlaced)
|
||||
|
@ -888,13 +889,13 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
|
||||
const f32 viScaleX = _FIXED2FLOAT(_SHIFTR(*REG.VI_X_SCALE, 0, 12), 10);
|
||||
const f32 srcScaleX = pFilteredBuffer->m_scaleX;
|
||||
const f32 dstScaleX = ogl.getScaleX();
|
||||
const f32 dstScaleX = wnd.getScaleX();
|
||||
const s32 h0 = (isPAL ? 128 : 108);
|
||||
const s32 hx0 = max(0, hStart - h0);
|
||||
const s32 hx1 = max(0, h0 + 640 - hEnd);
|
||||
X0 = (GLint)((hx0 * viScaleX + Xoffset) * dstScaleX);
|
||||
Xwidth = (GLint)((min((f32)VI.width, (hEnd - hStart)*viScaleX - Xoffset - Xdivot)) * srcScaleX);
|
||||
X1 = ogl.getWidth() - (GLint)((hx1*viScaleX + Xdivot) * dstScaleX);
|
||||
X1 = wnd.getWidth() - (GLint)((hx1*viScaleX + Xdivot) * dstScaleX);
|
||||
|
||||
const f32 srcScaleY = pFilteredBuffer->m_scaleY;
|
||||
CachedTexture * pBufferTexture = pFilteredBuffer->m_pTexture;
|
||||
|
@ -909,42 +910,67 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
return;
|
||||
}
|
||||
|
||||
const GLint hOffset = (ogl.getScreenWidth() - ogl.getWidth()) / 2;
|
||||
const GLint vOffset = (ogl.getScreenHeight() - ogl.getHeight()) / 2 + ogl.getHeightOffset();
|
||||
const GLint hOffset = (wnd.getScreenWidth() - wnd.getWidth()) / 2;
|
||||
const GLint vOffset = (wnd.getScreenHeight() - wnd.getHeight()) / 2 + wnd.getHeightOffset();
|
||||
GLint dstCoord[4] = { X0 + hOffset,
|
||||
vOffset + (GLint)(dstY0*dstScaleY),
|
||||
hOffset + X1,
|
||||
vOffset + (GLint)(dstY1*dstScaleY) };
|
||||
#ifdef GLESX
|
||||
#if 0 //def GLESX
|
||||
// TODO fix me
|
||||
if (render.getRenderer() == OGLRender::glrAdreno)
|
||||
dstCoord[0] += 1; // workaround for Adreno's issue with glBindFramebuffer;
|
||||
#endif // GLESX
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER, graphics::ObjectHandle());
|
||||
|
||||
//glDrawBuffer( GL_BACK );
|
||||
float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
render.clearColorBuffer(clearColor);
|
||||
drawer.clearColorBuffer(clearColor);
|
||||
|
||||
|
||||
GLenum filter = GL_LINEAR;
|
||||
graphics::ObjectHandle readBuffer;
|
||||
|
||||
if (pFilteredBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) {
|
||||
if (X0 > 0 || dstPartHeight > 0 ||
|
||||
(srcCoord[2] - srcCoord[0]) != (dstCoord[2] - dstCoord[0]) ||
|
||||
(srcCoord[3] - srcCoord[1]) != (dstCoord[3] - dstCoord[1])) {
|
||||
pFilteredBuffer->resolveMultisampledTexture(true);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_resolveFBO);
|
||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_resolveFBO);
|
||||
readBuffer = graphics::ObjectHandle(pFilteredBuffer->m_resolveFBO);
|
||||
} else {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
readBuffer = graphics::ObjectHandle(pFilteredBuffer->m_FBO);
|
||||
filter = GL_NEAREST;
|
||||
}
|
||||
} else
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
} else {
|
||||
readBuffer = graphics::ObjectHandle(pFilteredBuffer->m_FBO);
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
ogl.getRender().copyTexturedRect(srcCoord[0], srcCoord[1], srcCoord[2], srcCoord[3],
|
||||
pBufferTexture->realWidth, pBufferTexture->realHeight, pBufferTexture->glName,
|
||||
dstCoord[0], dstCoord[1], dstCoord[2], dstCoord[3],
|
||||
ogl.getScreenWidth(), ogl.getScreenHeight() + ogl.getHeightOffset(), filter);
|
||||
GraphicsDrawer::BlitOrCopyRectParams blitParams;
|
||||
blitParams.srcX0 = srcCoord[0];
|
||||
blitParams.srcY0 = srcCoord[1];
|
||||
blitParams.srcX1 = srcCoord[2];
|
||||
blitParams.srcY1 = srcCoord[3];
|
||||
blitParams.srcWidth = pBufferTexture->realWidth;
|
||||
blitParams.srcHeight = pBufferTexture->realHeight;
|
||||
blitParams.dstX0 = dstCoord[0];
|
||||
blitParams.dstY0 = dstCoord[1];
|
||||
blitParams.dstX1 = dstCoord[2];
|
||||
blitParams.dstY1 = dstCoord[3];
|
||||
blitParams.dstWidth = wnd.getScreenWidth();
|
||||
blitParams.dstHeight = wnd.getScreenHeight() + wnd.getHeightOffset();
|
||||
blitParams.filter = filter;
|
||||
blitParams.tex[0] = pBufferTexture;
|
||||
blitParams.combiner = CombinerInfo::get().getTexrectCopyProgram();
|
||||
blitParams.readBuffer = readBuffer;
|
||||
|
||||
drawer.blitOrCopyTexturedRect(blitParams);
|
||||
|
||||
if (dstPartHeight > 0) {
|
||||
const u32 size = *REG.VI_STATUS & 3;
|
||||
|
@ -958,22 +984,37 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
dstY1 = dstY0 + dstPartHeight;
|
||||
if (pFilteredBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) {
|
||||
pFilteredBuffer->resolveMultisampledTexture();
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_resolveFBO);
|
||||
} else
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
readBuffer = graphics::ObjectHandle(pFilteredBuffer->m_resolveFBO);
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_resolveFBO);
|
||||
} else {
|
||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO);
|
||||
readBuffer = graphics::ObjectHandle(pFilteredBuffer->m_FBO);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
pBufferTexture = pFilteredBuffer->m_pTexture;
|
||||
ogl.getRender().copyTexturedRect(0, (GLint)(srcY0*srcScaleY), Xwidth, min((GLint)(srcY1*srcScaleY), (GLint)pFilteredBuffer->m_pTexture->realHeight),
|
||||
pBufferTexture->realWidth, pBufferTexture->realHeight, pBufferTexture->glName,
|
||||
hOffset, vOffset + (GLint)(dstY0*dstScaleY), hOffset + X1, vOffset + (GLint)(dstY1*dstScaleY),
|
||||
ogl.getScreenWidth(), ogl.getScreenHeight() + ogl.getHeightOffset(), filter);
|
||||
|
||||
blitParams.srcX0 = 0;
|
||||
blitParams.srcY0 = (s32)(srcY0*srcScaleY);
|
||||
blitParams.srcX1 = Xwidth;
|
||||
blitParams.srcY1 = min((s32)(srcY1*srcScaleY), (s32)pFilteredBuffer->m_pTexture->realHeight);
|
||||
blitParams.srcWidth = pBufferTexture->realWidth;
|
||||
blitParams.srcHeight = pBufferTexture->realHeight;
|
||||
blitParams.dstX0 = hOffset;
|
||||
blitParams.dstY0 = vOffset + (s32)(dstY0*dstScaleY);
|
||||
blitParams.dstX1 = hOffset + X1;
|
||||
blitParams.dstY1 = vOffset + (s32)(dstY1*dstScaleY);
|
||||
blitParams.dstWidth = wnd.getScreenWidth();
|
||||
blitParams.dstHeight = wnd.getScreenHeight() + wnd.getHeightOffset();
|
||||
blitParams.tex[0] = pBufferTexture;
|
||||
|
||||
drawer.blitOrCopyTexturedRect(blitParams);
|
||||
}
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
ogl.swapBuffers();
|
||||
wnd.swapBuffers();
|
||||
if (m_pCurrent != nullptr) {
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_FBO);
|
||||
#ifdef VC
|
||||
|
|
|
@ -5,17 +5,21 @@ using namespace graphics;
|
|||
|
||||
Context gfxContext;
|
||||
|
||||
bool Context::imageTextures = false;
|
||||
|
||||
Context::Context() {}
|
||||
|
||||
Context::~Context() {
|
||||
m_impl.reset();
|
||||
}
|
||||
|
||||
|
||||
void Context::init()
|
||||
{
|
||||
m_impl.reset(new opengl::ContextImpl);
|
||||
m_impl->init();
|
||||
m_fbTexFormats.reset(m_impl->getFramebufferTextureFormats());
|
||||
imageTextures = isSupported(SpecialFeatures::ImageTextures);
|
||||
}
|
||||
|
||||
void Context::destroy()
|
||||
|
@ -121,6 +125,11 @@ void Context::deleteFramebuffer(ObjectHandle _name)
|
|||
m_impl->deleteFramebuffer(_name);
|
||||
}
|
||||
|
||||
void Context::bindFramebuffer(Parameter _target, ObjectHandle _name)
|
||||
{
|
||||
m_impl->bindFramebuffer(_target, _name);
|
||||
}
|
||||
|
||||
ObjectHandle Context::createRenderbuffer()
|
||||
{
|
||||
return m_impl->createRenderbuffer();
|
||||
|
@ -218,8 +227,13 @@ f32 Context::getMaxLineWidth()
|
|||
return m_impl->getMaxLineWidth();
|
||||
}
|
||||
|
||||
bool Context::isError() const
|
||||
{
|
||||
return m_impl->isError();
|
||||
}
|
||||
|
||||
bool Context::isSupported(SpecialFeatures _feature) const
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace graphics {
|
|||
enum class SpecialFeatures {
|
||||
Multisampling,
|
||||
NearPlaneClipping,
|
||||
FragmentDepthWrite
|
||||
FragmentDepthWrite,
|
||||
ImageTextures
|
||||
};
|
||||
|
||||
class ContextImpl;
|
||||
|
@ -114,6 +115,8 @@ namespace graphics {
|
|||
|
||||
void deleteFramebuffer(ObjectHandle _name);
|
||||
|
||||
void bindFramebuffer(Parameter _target, ObjectHandle _name);
|
||||
|
||||
ObjectHandle createRenderbuffer();
|
||||
|
||||
struct InitRenderbufferParams {
|
||||
|
@ -213,6 +216,10 @@ namespace graphics {
|
|||
|
||||
bool isSupported(SpecialFeatures _feature) const;
|
||||
|
||||
bool isError() const;
|
||||
|
||||
static bool imageTextures;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ContextImpl> m_impl;
|
||||
std::unique_ptr<FramebufferTextureFormats> m_fbTexFormats;
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace graphics {
|
|||
virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
|
||||
virtual ObjectHandle createFramebuffer() = 0;
|
||||
virtual void deleteFramebuffer(ObjectHandle _name) = 0;
|
||||
virtual void bindFramebuffer(Parameter _target, ObjectHandle _name) = 0;
|
||||
virtual void addFrameBufferRenderTarget(const Context::FrameBufferRenderTarget & _params) = 0;
|
||||
virtual ObjectHandle createRenderbuffer() = 0;
|
||||
virtual void initRenderbuffer(const Context::InitRenderbufferParams & _params) = 0;
|
||||
|
@ -50,6 +51,7 @@ namespace graphics {
|
|||
virtual f32 getMaxLineWidth() = 0;
|
||||
virtual void drawText(const char *_pText, float _x, float _y) = 0;
|
||||
virtual void getTextSize(const char *_pText, float & _w, float & _h) = 0;
|
||||
virtual bool isError() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <Textures.h>
|
||||
#include <NoiseTexture.h>
|
||||
#include <FrameBuffer.h>
|
||||
#include <DisplayWindow.h>
|
||||
#include <GBI.h>
|
||||
#include <RSP.h>
|
||||
#include <gSP.h>
|
||||
|
@ -372,8 +373,8 @@ public:
|
|||
{
|
||||
if (config.frameBufferEmulation.nativeResFactor == 0)
|
||||
// TODO fix me
|
||||
//uScreenScale.set(video().getScaleX(), video().getScaleY(), _force);
|
||||
uScreenScale.set(2.0f, 2.0f, _force);
|
||||
uScreenScale.set(dwnd().getScaleX(), dwnd().getScaleY(), _force);
|
||||
// uScreenScale.set(2.0f, 2.0f, _force);
|
||||
else
|
||||
uScreenScale.set(float(config.frameBufferEmulation.nativeResFactor), float(config.frameBufferEmulation.nativeResFactor), _force);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "opengl_ContextImpl.h"
|
||||
#include "opengl_UnbufferedDrawer.h"
|
||||
#include "opengl_DummyTextDrawer.h"
|
||||
#include "opengl_Utils.h"
|
||||
#include "GLSL/glsl_CombinerProgramBuilder.h"
|
||||
#include "GLSL/glsl_SpecialShadersFactory.h"
|
||||
#include "GLSL/glsl_ShaderStorage.h"
|
||||
|
@ -191,6 +192,11 @@ void ContextImpl::deleteFramebuffer(graphics::ObjectHandle _name)
|
|||
glDeleteFramebuffers(1, &fbo);
|
||||
}
|
||||
|
||||
void ContextImpl::bindFramebuffer(graphics::Parameter _target, graphics::ObjectHandle _name)
|
||||
{
|
||||
m_cachedFunctions->geCachedBindFramebuffer()->bind(_target, _name);
|
||||
}
|
||||
|
||||
graphics::ObjectHandle ContextImpl::createRenderbuffer()
|
||||
{
|
||||
return m_createRenderbuffer->createRenderbuffer();
|
||||
|
@ -312,3 +318,8 @@ void ContextImpl::getTextSize(const char *_pText, float & _w, float & _h)
|
|||
{
|
||||
m_textDrawer->getTextSize(_pText, _w, _h);
|
||||
}
|
||||
|
||||
bool ContextImpl::isError() const
|
||||
{
|
||||
return Utils::isGLError();
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ namespace opengl {
|
|||
|
||||
void deleteFramebuffer(graphics::ObjectHandle _name) override;
|
||||
|
||||
void bindFramebuffer(graphics::Parameter _target, graphics::ObjectHandle _name) override;
|
||||
|
||||
graphics::ObjectHandle createRenderbuffer() override;
|
||||
|
||||
void initRenderbuffer(const graphics::Context::InitRenderbufferParams & _params) override;
|
||||
|
@ -106,6 +108,8 @@ namespace opengl {
|
|||
|
||||
void getTextSize(const char *_pText, float & _w, float & _h) override;
|
||||
|
||||
bool isError() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<CachedFunctions> m_cachedFunctions;
|
||||
std::unique_ptr<Create2DTexture> m_createTexture;
|
||||
|
|
|
@ -104,4 +104,10 @@ namespace graphics {
|
|||
Parameter TRIANGLE_STRIP(GL_TRIANGLE_STRIP);
|
||||
Parameter LINES(GL_LINES);
|
||||
}
|
||||
|
||||
namespace blitMask {
|
||||
Parameter COLOR_BUFFER(GL_COLOR_BUFFER_BIT);
|
||||
Parameter DEPTH_BUFFER(GL_DEPTH_BUFFER_BIT);
|
||||
Parameter STENCIL_BUFFER(GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,4 +104,10 @@ namespace graphics {
|
|||
extern Parameter TRIANGLE_STRIP;
|
||||
extern Parameter LINES;
|
||||
}
|
||||
|
||||
namespace blitMask {
|
||||
extern Parameter COLOR_BUFFER;
|
||||
extern Parameter DEPTH_BUFFER;
|
||||
extern Parameter STENCIL_BUFFER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ float _adjustViewportX(f32 _X0)
|
|||
{
|
||||
const f32 halfX = gDP.colorImage.width / 2.0f;
|
||||
const f32 halfVP = gSP.viewport.width / 2.0f;
|
||||
return (_X0 + halfVP - halfX) * video().getAdjustScale() + halfX - halfVP;
|
||||
return (_X0 + halfVP - halfX) * dwnd().getAdjustScale() + halfX - halfVP;
|
||||
}
|
||||
|
||||
void GraphicsDrawer::_updateViewport() const
|
||||
|
@ -807,7 +807,7 @@ void GraphicsDrawer::drawLine(int _v0, int _v1, float _width)
|
|||
|
||||
GLfloat lineWidth = _width;
|
||||
if (config.frameBufferEmulation.nativeResFactor == 0)
|
||||
lineWidth *= video().getScaleX();
|
||||
lineWidth *= dwnd().getScaleX();
|
||||
else
|
||||
lineWidth *= config.frameBufferEmulation.nativeResFactor;
|
||||
if (lineWidth > m_maxLineWidth) {
|
||||
|
@ -843,9 +843,9 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pC
|
|||
m_drawingState = DrawingState::Rect;
|
||||
|
||||
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||
OGLVideo & ogl = video();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
if (pCurrentBuffer == nullptr)
|
||||
gfxContext.setViewport(0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
||||
gfxContext.setViewport(0, wnd.getHeightOffset(), wnd.getScreenWidth(), wnd.getScreenHeight());
|
||||
else
|
||||
gfxContext.setViewport(0, 0, pCurrentBuffer->m_width*pCurrentBuffer->m_scaleX, pCurrentBuffer->m_height*pCurrentBuffer->m_scaleY);
|
||||
|
||||
|
@ -872,8 +872,8 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pC
|
|||
m_rect[3].z = Z;
|
||||
m_rect[3].w = W;
|
||||
|
||||
if (ogl.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100) && (_lrx - _ulx < VI.width * 9 / 10)) {
|
||||
const float scale = ogl.getAdjustScale();
|
||||
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100) && (_lrx - _ulx < VI.width * 9 / 10)) {
|
||||
const float scale = wnd.getAdjustScale();
|
||||
for (u32 i = 0; i < 4; ++i)
|
||||
m_rect[i].x *= scale;
|
||||
}
|
||||
|
@ -897,16 +897,12 @@ bool texturedRectShadowMap(const GraphicsDrawer::TexturedRectParams &)
|
|||
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||
if (pCurrentBuffer != nullptr) {
|
||||
if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
|
||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||
if (video().getRender().isImageTexturesSupported()) {
|
||||
if (Context::imageTextures) {
|
||||
pCurrentBuffer->m_pDepthBuffer->activateDepthBufferTexture(pCurrentBuffer);
|
||||
CombinerInfo::get().setDepthFogCombiner();
|
||||
}
|
||||
else
|
||||
return true;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -929,8 +925,8 @@ bool texturedRectDepthBufferCopy(const GraphicsDrawer::TexturedRectParams & _par
|
|||
return true;
|
||||
pBuffer->m_cleared = true;
|
||||
if (config.frameBufferEmulation.copyDepthToRDRAM == Config::cdCopyFromVRam) {
|
||||
if (rectDepthBufferCopyFrame != video().getBuffersSwapCount()) {
|
||||
rectDepthBufferCopyFrame = video().getBuffersSwapCount();
|
||||
if (rectDepthBufferCopyFrame != dwnd().getBuffersSwapCount()) {
|
||||
rectDepthBufferCopyFrame = dwnd().getBuffersSwapCount();
|
||||
if (!FrameBuffer_CopyDepthBuffer(gDP.colorImage.address))
|
||||
return true;
|
||||
}
|
||||
|
@ -1087,7 +1083,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
|
||||
CombinerProgram * pCurrentCombiner = currentCombiner();
|
||||
const FrameBuffer * pCurrentBuffer = _params.pBuffer;
|
||||
OGLVideo & ogl = video();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
TextureCache & cache = textureCache();
|
||||
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
|
||||
const bool bUseTexrectDrawer = config.generalEmulation.enableNativeResTexrects != 0
|
||||
|
@ -1236,11 +1232,11 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
m_rect[2].t1 = texST[1].t1;
|
||||
}
|
||||
|
||||
if (ogl.isAdjustScreen() &&
|
||||
if (wnd.isAdjustScreen() &&
|
||||
(_params.forceAjustScale ||
|
||||
((gDP.colorImage.width > VI.width * 98 / 100) && (_params.lrx - _params.ulx < VI.width * 9 / 10))))
|
||||
{
|
||||
const float scale = ogl.getAdjustScale();
|
||||
const float scale = wnd.getAdjustScale();
|
||||
for (u32 i = 0; i < 4; ++i)
|
||||
m_rect[i].x *= scale;
|
||||
}
|
||||
|
@ -1249,7 +1245,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
m_texrectDrawer.add();
|
||||
else {
|
||||
if (pCurrentBuffer == nullptr)
|
||||
gfxContext.setViewport(0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
||||
gfxContext.setViewport(0, wnd.getHeightOffset(), wnd.getScreenWidth(), wnd.getScreenHeight());
|
||||
else
|
||||
gfxContext.setViewport(0, 0, pCurrentBuffer->m_width*pCurrentBuffer->m_scaleX, pCurrentBuffer->m_height*pCurrentBuffer->m_scaleY);
|
||||
|
||||
|
@ -1493,6 +1489,8 @@ void GraphicsDrawer::blitOrCopyTexturedRect(const BlitOrCopyRectParams & _params
|
|||
if (gfxContext.blitFramebuffers(blitParams))
|
||||
return;
|
||||
|
||||
gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, _params.readBuffer);
|
||||
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, _params.drawBuffer);
|
||||
copyTexturedRect(_params);
|
||||
}
|
||||
|
||||
|
@ -1564,6 +1562,7 @@ void GraphicsDrawer::_initData()
|
|||
FBInfo::fbInfo.reset();
|
||||
m_texrectDrawer.init();
|
||||
m_drawingState = DrawingState::None;
|
||||
m_bImageTexture = gfxContext.isSupported(SpecialFeatures::ImageTextures);
|
||||
|
||||
gSP.changed = gDP.changed = 0xFFFFFFFF;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
namespace graphics {
|
||||
class DrawerImpl;
|
||||
class TextDrawer;
|
||||
class CombinerProgram;
|
||||
}
|
||||
|
||||
struct CachedTexture;
|
||||
|
@ -35,8 +36,6 @@ struct RectVertex
|
|||
class GraphicsDrawer
|
||||
{
|
||||
public:
|
||||
GraphicsDrawer();
|
||||
|
||||
void addTriangle(int _v0, int _v1, int _v2);
|
||||
|
||||
void drawTriangles();
|
||||
|
@ -138,8 +137,14 @@ public:
|
|||
|
||||
void dropRenderState() { m_drawingState = DrawingState::None; }
|
||||
|
||||
void flush() { m_texrectDrawer.draw(); }
|
||||
|
||||
private:
|
||||
GraphicsDrawer(const GraphicsDrawer &);
|
||||
friend class DisplayWindow;
|
||||
|
||||
GraphicsDrawer();
|
||||
|
||||
GraphicsDrawer(const GraphicsDrawer &) = delete;
|
||||
|
||||
void _initStates();
|
||||
void _initData();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "VI.h"
|
||||
#include "Textures.h"
|
||||
#include "NoiseTexture.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
NoiseTexture g_noiseTexture;
|
||||
|
||||
|
@ -68,7 +69,7 @@ void NoiseTexture::update()
|
|||
{
|
||||
if (!m_pbuf || m_pTexture == nullptr)
|
||||
return;
|
||||
if (m_DList == video().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
|
||||
if (m_DList == dwnd().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
|
||||
return;
|
||||
const u32 dataSize = VI.width*VI.height;
|
||||
if (dataSize == 0)
|
||||
|
@ -95,5 +96,5 @@ void NoiseTexture::update()
|
|||
params.data = m_pbuf->getData();
|
||||
gfxContext.update2DTexture(params);
|
||||
|
||||
m_DList = video().getBuffersSwapCount();
|
||||
m_DList = dwnd().getBuffersSwapCount();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
//#define NEW_POST_PROCESSOR
|
||||
|
||||
|
@ -286,8 +287,8 @@ void _initTexture(CachedTexture * pTexture)
|
|||
pTexture->maskT = 0;
|
||||
pTexture->mirrorS = 0;
|
||||
pTexture->mirrorT = 0;
|
||||
pTexture->realWidth = video().getWidth();
|
||||
pTexture->realHeight = video().getHeight();
|
||||
pTexture->realWidth = dwnd().getWidth();
|
||||
pTexture->realHeight = dwnd().getHeight();
|
||||
pTexture->textureBytes = pTexture->realWidth * pTexture->realHeight * 4;
|
||||
textureCache().addFrameBufferTextureSize(pTexture->textureBytes);
|
||||
|
||||
|
@ -393,7 +394,7 @@ void PostProcessor::_initBlur()
|
|||
glUniform1i(loc, 0);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "TexelSize");
|
||||
assert(loc >= 0);
|
||||
glUniform2f(loc, 1.0f / video().getWidth(), 1.0f / video().getHeight());
|
||||
glUniform2f(loc, 1.0f / dwnd().getWidth(), 1.0f / dwnd().getHeight());
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "Orientation");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
|
@ -538,7 +539,7 @@ void PostProcessor::_setGLState() {
|
|||
glVertexAttribPointer(SC_RECT_POSITION, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (float*)vert);
|
||||
glEnableVertexAttribArray(SC_TEXCOORD0);
|
||||
glVertexAttribPointer(SC_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (float*)vert + 2);
|
||||
glViewport(0, 0, video().getWidth(), video().getHeight());
|
||||
glViewport(0, 0, dwnd().getWidth(), dwnd().getHeight());
|
||||
glScissor(0, 0, m_pResultBuffer->m_pTexture->realWidth, m_pResultBuffer->m_pTexture->realHeight);
|
||||
gSP.changed |= CHANGED_VIEWPORT;
|
||||
gDP.changed |= CHANGED_RENDERMODE | CHANGED_SCISSOR;
|
||||
|
@ -549,12 +550,11 @@ void PostProcessor::_preDraw(FrameBuffer * _pBuffer)
|
|||
#ifndef NEW_POST_PROCESSOR
|
||||
_setGLState();
|
||||
#endif
|
||||
OGLVideo & ogl = video();
|
||||
|
||||
m_pResultBuffer->m_width = _pBuffer->m_width;
|
||||
m_pResultBuffer->m_height = _pBuffer->m_height;
|
||||
m_pResultBuffer->m_scaleX = ogl.getScaleX();
|
||||
m_pResultBuffer->m_scaleY = ogl.getScaleY();
|
||||
m_pResultBuffer->m_scaleX = dwnd().getScaleX();
|
||||
m_pResultBuffer->m_scaleY = dwnd().getScaleY();
|
||||
#ifdef GLES2
|
||||
m_pTextureOriginal = _pBuffer->m_pTexture;
|
||||
#else
|
||||
|
@ -572,7 +572,7 @@ void PostProcessor::_postDraw()
|
|||
{
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
#ifndef NEW_POST_PROCESSOR
|
||||
video().getRender().dropRenderState();
|
||||
dwnd().getDrawer().dropRenderState();
|
||||
#endif
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "OpenGL.h"
|
||||
#include "Config.h"
|
||||
#include "Debug.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
void RDP_Unknown( u32 w0, u32 w1 )
|
||||
{
|
||||
|
@ -550,7 +551,7 @@ inline u32 READ_RDP_DATA(u32 address)
|
|||
|
||||
void RDP_ProcessRDPList()
|
||||
{
|
||||
if (ConfigOpen || video().isResizeWindow()) {
|
||||
if (ConfigOpen || dwnd().isResizeWindow()) {
|
||||
dp_status &= ~0x0002;
|
||||
dp_start = dp_current = dp_end;
|
||||
gDPFullSync();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "PluginAPI.h"
|
||||
#include "Config.h"
|
||||
#include "TextureFilterHandler.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -139,14 +140,14 @@ void RSP_CheckDLCounter()
|
|||
|
||||
void RSP_ProcessDList()
|
||||
{
|
||||
if (ConfigOpen || video().isResizeWindow()) {
|
||||
if (ConfigOpen || dwnd().isResizeWindow()) {
|
||||
*REG.MI_INTR |= MI_INTR_DP;
|
||||
CheckInterrupts();
|
||||
return;
|
||||
}
|
||||
if (*REG.VI_ORIGIN != VI.lastOrigin) {
|
||||
VI_UpdateSize();
|
||||
video().updateScale();
|
||||
dwnd().updateScale();
|
||||
}
|
||||
|
||||
RSP.PC[0] = *(u32*)&DMEM[0x0FF0];
|
||||
|
@ -220,7 +221,7 @@ void RSP_ProcessDList()
|
|||
if ((config.generalEmulation.hacks & hack_rectDepthBufferCopyCBFD) != 0) {
|
||||
; // do nothing
|
||||
} else if ((config.generalEmulation.hacks & hack_rectDepthBufferCopyPD) != 0) {
|
||||
if (rectDepthBufferCopyFrame == video().getBuffersSwapCount())
|
||||
if (rectDepthBufferCopyFrame == dwnd().getBuffersSwapCount())
|
||||
FrameBuffer_CopyDepthBuffer(gDP.colorImage.address);
|
||||
} else if (!FBInfo::fbInfo.isSupported())
|
||||
FrameBuffer_CopyDepthBuffer(gDP.colorImage.address);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
struct point {
|
||||
GLfloat x;
|
||||
|
@ -316,9 +317,9 @@ void TextDrawer::renderText(const char *_pText, float _x, float _y) const
|
|||
{
|
||||
if (m_pAtlas == nullptr)
|
||||
return;
|
||||
OGLVideo & ogl = video();
|
||||
const float sx = 2.0f / ogl.getWidth();
|
||||
const float sy = 2.0f / ogl.getHeight();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
const float sx = 2.0f / wnd.getWidth();
|
||||
const float sy = 2.0f / wnd.getHeight();
|
||||
|
||||
const u8 *p;
|
||||
|
||||
|
@ -389,9 +390,9 @@ void TextDrawer::getTextSize(const char *_pText, float & _w, float & _h) const
|
|||
_w = _h = 0;
|
||||
if (m_pAtlas == nullptr)
|
||||
return;
|
||||
OGLVideo & ogl = video();
|
||||
const float sx = 2.0f / ogl.getWidth();
|
||||
const float sy = 2.0f / ogl.getHeight();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
const float sx = 2.0f / wnd.getWidth();
|
||||
const float sy = 2.0f / wnd.getHeight();
|
||||
float bw, bh;
|
||||
|
||||
for (const u8 *p = (const u8 *)_pText; *p; ++p) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "PluginAPI.h"
|
||||
#include "FrameBuffer.h"
|
||||
#include "TextureFilterHandler.h"
|
||||
#include "DisplayWindow.h"
|
||||
#include "wst.h"
|
||||
|
||||
static
|
||||
|
@ -67,10 +68,10 @@ void displayLoadProgress(const wchar_t *format, ...)
|
|||
if (pBuffer != nullptr)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.clearColorBuffer(nullptr);
|
||||
render.drawText(buf, -0.9f, 0);
|
||||
video().swapBuffers();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.clearColorBuffer(nullptr);
|
||||
drawer.drawText(buf, -0.9f, 0);
|
||||
dwnd().swapBuffers();
|
||||
|
||||
if (pBuffer != nullptr)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pBuffer->m_FBO);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "TextureFilterHandler.h"
|
||||
#include "Graphics/Context.h"
|
||||
#include "Graphics/Parameters.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1315,7 +1316,7 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
|||
_pTexture->mirrorT ? graphics::textureParameters::WRAP_MIRRORED_REPEAT
|
||||
: graphics::textureParameters::WRAP_REPEAT;
|
||||
|
||||
if (video().getRender().getRenderState() == OGLRender::rsTriangle && config.texture.maxAnisotropyF > 0.0f)
|
||||
if (dwnd().getDrawer().getDrawingState() == DrawingState::Triangle && config.texture.maxAnisotropyF > 0.0f)
|
||||
params.maxAnisotropy = graphics::Parameter(config.texture.maxAnisotropyF);
|
||||
|
||||
gfxContext.setTextureParameters(params);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "RDP.h"
|
||||
#include "gSP.h"
|
||||
#include "gDP.h"
|
||||
#include "OpenGL.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
/******************Turbo3D microcode*************************/
|
||||
|
||||
|
@ -126,7 +126,7 @@ void Turbo3D_LoadObject(u32 pstate, u32 pvtx, u32 ptri)
|
|||
addr += 4;
|
||||
gSPTriangle(tri->v0, tri->v1, tri->v2);
|
||||
}
|
||||
video().getRender().drawTriangles();
|
||||
dwnd().getDrawer().drawTriangles();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
15
src/VI.cpp
15
src/VI.cpp
|
@ -13,6 +13,7 @@
|
|||
#include "Config.h"
|
||||
#include "Performance.h"
|
||||
#include "Debug.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -98,18 +99,18 @@ void VI_UpdateScreen()
|
|||
return;
|
||||
|
||||
perf.increaseVICount();
|
||||
OGLVideo & ogl = video();
|
||||
if (ogl.changeWindow())
|
||||
DisplayWindow & wnd = dwnd();
|
||||
if (wnd.changeWindow())
|
||||
return;
|
||||
if (ogl.resizeWindow())
|
||||
if (wnd.resizeWindow())
|
||||
return;
|
||||
ogl.saveScreenshot();
|
||||
wnd.saveScreenshot();
|
||||
|
||||
bool bVIUpdated = false;
|
||||
if (*REG.VI_ORIGIN != VI.lastOrigin) {
|
||||
VI_UpdateSize();
|
||||
bVIUpdated = true;
|
||||
ogl.updateScale();
|
||||
wnd.updateScale();
|
||||
}
|
||||
|
||||
if (config.frameBufferEmulation.enable) {
|
||||
|
@ -142,7 +143,7 @@ void VI_UpdateScreen()
|
|||
if (pBuffer == nullptr || pBuffer->m_width != VI.width) {
|
||||
if (!bVIUpdated) {
|
||||
VI_UpdateSize();
|
||||
ogl.updateScale();
|
||||
wnd.updateScale();
|
||||
bVIUpdated = true;
|
||||
}
|
||||
const u32 size = *REG.VI_STATUS & 3;
|
||||
|
@ -165,7 +166,7 @@ void VI_UpdateScreen()
|
|||
}
|
||||
else {
|
||||
if (gDP.changed & CHANGED_COLORBUFFER) {
|
||||
ogl.swapBuffers();
|
||||
wnd.swapBuffers();
|
||||
gDP.changed &= ~CHANGED_COLORBUFFER;
|
||||
VI.lastOrigin = *REG.VI_ORIGIN;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "gDP.h"
|
||||
#include "Log.h"
|
||||
#include "F3D.h"
|
||||
#include "OpenGL.h"
|
||||
#include "3DMath.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
#define GZM_USER0 0
|
||||
#define GZM_USER1 2
|
||||
|
@ -132,9 +132,9 @@ void ZSort_DrawObject (u8 * _addr, u32 _type)
|
|||
break;
|
||||
}
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(vnum);
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(vnum);
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
for (u32 i = 0; i < vnum; ++i) {
|
||||
SPVertex & vtx = pVtx[i];
|
||||
vtx.x = _FIXED2FLOAT(((s16*)_addr)[0 ^ 1], 2);
|
||||
|
@ -156,7 +156,7 @@ void ZSort_DrawObject (u8 * _addr, u32 _type)
|
|||
|
||||
_addr += vsize;
|
||||
}
|
||||
render.drawScreenSpaceTriangle(vnum);
|
||||
drawer.drawScreenSpaceTriangle(vnum);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -285,9 +285,9 @@ void ZSort_Lighting( u32 _w0, u32 _w1 )
|
|||
u32 tdest = -1024 + _SHIFTR(_w1, 0, 12);
|
||||
int use_material = (csrs != 0x0ff0);
|
||||
tdest >>= 1;
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(num);
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(num);
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
for (u32 i = 0; i < num; i++) {
|
||||
SPVertex & vtx = pVtx[i];
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <N64.h>
|
||||
#include <GLideN64.h>
|
||||
#include <OpenGL.h>
|
||||
#include <RSP.h>
|
||||
#include <RDP.h>
|
||||
#include <VI.h>
|
||||
|
@ -18,6 +17,8 @@
|
|||
#include <FrameBufferInfo.h>
|
||||
#include <TextureFilterHandler.h>
|
||||
#include <Log.h>
|
||||
#include "Graphics/Context.h"
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
PluginAPI & PluginAPI::get()
|
||||
{
|
||||
|
@ -37,8 +38,8 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
RSP_Init();
|
||||
GBI.init();
|
||||
Config_LoadConfig();
|
||||
video().start();
|
||||
assert(!isGLError());
|
||||
dwnd().start();
|
||||
assert(!gfxContext.isError());
|
||||
|
||||
while (true) {
|
||||
_pPluginThreadMtx->lock();
|
||||
|
@ -47,7 +48,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
_pRspThreadCv->wait(*_pRspThreadMtx);
|
||||
if (*_pCommand != nullptr && !(*_pCommand)->run())
|
||||
return;
|
||||
assert(!isGLError());
|
||||
assert(!gfxContext.isError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,7 @@ public:
|
|||
}
|
||||
|
||||
bool run() {
|
||||
video().readScreen(m_dest, m_width, m_height);
|
||||
dwnd().readScreen(m_dest, m_width, m_height);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -133,7 +134,7 @@ public:
|
|||
|
||||
bool run() {
|
||||
TFH.shutdown();
|
||||
video().stop();
|
||||
dwnd().stop();
|
||||
GBI.destroy();
|
||||
m_pRspThreadMtx->unlock();
|
||||
m_pPluginThreadMtx->lock();
|
||||
|
@ -184,7 +185,7 @@ void PluginAPI::RomClosed()
|
|||
m_pRspThread = nullptr;
|
||||
#else
|
||||
TFH.shutdown();
|
||||
video().stop();
|
||||
dwnd().stop();
|
||||
GBI.destroy();
|
||||
#endif
|
||||
|
||||
|
@ -206,7 +207,7 @@ void PluginAPI::RomOpen()
|
|||
RSP_Init();
|
||||
GBI.init();
|
||||
Config_LoadConfig();
|
||||
video().start();
|
||||
dwnd().start();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -265,7 +266,7 @@ void PluginAPI::_initiateGFX(const GFX_INFO & _gfxInfo) const {
|
|||
|
||||
void PluginAPI::ChangeWindow()
|
||||
{
|
||||
video().setToggleFullscreen();
|
||||
dwnd().setToggleFullscreen();
|
||||
}
|
||||
|
||||
void PluginAPI::FBWrite(unsigned int _addr, unsigned int _size)
|
||||
|
@ -298,7 +299,7 @@ void PluginAPI::ReadScreen(void **_dest, long *_width, long *_height)
|
|||
#ifdef RSPTHREAD
|
||||
_callAPICommand(ReadScreenCommand(_dest, _width, _height));
|
||||
#else
|
||||
video().readScreen(_dest, _width, _height);
|
||||
dwnd().readScreen(_dest, _width, _height);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
33
src/gDP.cpp
33
src/gDP.cpp
|
@ -21,6 +21,7 @@
|
|||
#include "Config.h"
|
||||
#include "Combiner.h"
|
||||
#include "Performance.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -735,7 +736,7 @@ void gDPSetScissor( u32 mode, f32 ulx, f32 uly, f32 lrx, f32 lry )
|
|||
|
||||
void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
++lrx;
|
||||
++lry;
|
||||
|
@ -750,7 +751,7 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
frameBufferList().fillRDRAM(ulx, uly, lrx, lry);
|
||||
if (config.generalEmulation.enableFragmentDepthWrite == 0 ||
|
||||
(ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry)) {
|
||||
render.clearDepthBuffer(ulx, uly, lrx, lry);
|
||||
drawer.clearDepthBuffer(ulx, uly, lrx, lry);
|
||||
bBufferCleared = true;
|
||||
} else
|
||||
depthBufferList().clearBuffer(ulx, uly, lrx, lry);
|
||||
|
@ -760,7 +761,7 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
frameBufferList().fillRDRAM(ulx, uly, lrx, lry);
|
||||
if (config.generalEmulation.enableFragmentDepthWrite == 0 ||
|
||||
(ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry)) {
|
||||
render.clearDepthBuffer(ulx, uly, lrx, lry);
|
||||
drawer.clearDepthBuffer(ulx, uly, lrx, lry);
|
||||
bBufferCleared = true;
|
||||
} else
|
||||
depthBufferList().clearBuffer(ulx, uly, lrx, lry);
|
||||
|
@ -774,11 +775,11 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
if ((ulx == 0) && (uly == 0) && (lrx == gDP.scissor.lrx) && (lry == gDP.scissor.lry)) {
|
||||
frameBufferList().fillRDRAM(ulx, uly, lrx, lry);
|
||||
render.clearColorBuffer(fillColor);
|
||||
drawer.clearColorBuffer(fillColor);
|
||||
} else
|
||||
render.drawRect(ulx, uly, lrx, lry, fillColor);
|
||||
drawer.drawRect(ulx, uly, lrx, lry, fillColor);
|
||||
} else
|
||||
render.drawRect(ulx, uly, lrx, lry, fillColor);
|
||||
drawer.drawRect(ulx, uly, lrx, lry, fillColor);
|
||||
}
|
||||
|
||||
if (lrx == gDP.colorImage.width) {
|
||||
|
@ -857,12 +858,12 @@ void gDPTextureRectangle(f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f3
|
|||
lrt = t + (lry - uly - 1) * dtdy;
|
||||
}
|
||||
|
||||
OGLRender::TexturedRectParams params(ulx, uly, lrx, lry, s, t, lrs, lrt, fabsf(dsdx), fabsf(dtdy),
|
||||
flip, false, true, frameBufferList().getCurrent());
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
GraphicsDrawer::TexturedRectParams params(ulx, uly, lrx, lry, s, t, lrs, lrt, fabsf(dsdx), fabsf(dtdy),
|
||||
flip, false, true, frameBufferList().getCurrent());
|
||||
if (config.generalEmulation.enableNativeResTexrects == 0 && config.generalEmulation.correctTexrectCoords != Config::tcDisable)
|
||||
render.correctTexturedRectParams(params);
|
||||
render.drawTexturedRect(params);
|
||||
drawer.correctTexturedRectParams(params);
|
||||
drawer.drawTexturedRect(params);
|
||||
|
||||
gSP.textureTile[0] = textureTileOrg[0];
|
||||
gSP.textureTile[1] = textureTileOrg[1];
|
||||
|
@ -890,7 +891,7 @@ void gDPFullSync()
|
|||
frameBufferList().removeAux();
|
||||
}
|
||||
|
||||
video().getRender().flush();
|
||||
dwnd().getDrawer().flush();
|
||||
|
||||
const bool sync = config.frameBufferEmulation.copyToRDRAM == Config::ctSync;
|
||||
if ((config.frameBufferEmulation.copyToRDRAM != Config::ctDisable || (config.generalEmulation.hacks & hack_subscreen) != 0) &&
|
||||
|
@ -1058,9 +1059,9 @@ void gDPLLETriangle(u32 _w1, u32 _w2, int _shade, int _texture, int _zbuffer, u3
|
|||
#define SSCALE(s, _w) (PERSP_EN? float(PERSP(s, _w))/(1 << 10) : float(s)/(1<<21))
|
||||
#define TSCALE(s, w) (PERSP_EN? float(PERSP(s, w))/(1 << 10) : float(s)/(1<<21))
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(16);
|
||||
SPVertex * vtx0 = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(16);
|
||||
SPVertex * vtx0 = drawer.getDMAVerticesData();
|
||||
SPVertex * vtx = vtx0;
|
||||
|
||||
xleft = xm;
|
||||
|
@ -1243,7 +1244,7 @@ void gDPLLETriangle(u32 _w1, u32 _w2, int _shade, int _texture, int _zbuffer, u3
|
|||
if (_zbuffer != 0)
|
||||
gSP.geometryMode |= G_ZBUFFER;
|
||||
|
||||
render.drawScreenSpaceTriangle(vtx - vtx0);
|
||||
drawer.drawScreenSpaceTriangle(vtx - vtx0);
|
||||
gSP.textureTile[0] = textureTileOrg[0];
|
||||
gSP.textureTile[1] = textureTileOrg[1];
|
||||
}
|
||||
|
|
178
src/gSP.cpp
178
src/gSP.cpp
|
@ -21,6 +21,7 @@
|
|||
#include "DepthBuffer.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -29,7 +30,7 @@ using namespace std;
|
|||
void gSPFlushTriangles()
|
||||
{
|
||||
if ((gSP.geometryMode & G_SHADING_SMOOTH) == 0) {
|
||||
video().getRender().drawTriangles();
|
||||
dwnd().getDrawer().drawTriangles();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,8 +39,9 @@ void gSPFlushTriangles()
|
|||
(RSP.nextCmd != G_TRI2) &&
|
||||
(RSP.nextCmd != G_TRIX) &&
|
||||
(RSP.nextCmd != G_QUAD)
|
||||
)
|
||||
video().getRender().drawTriangles();
|
||||
) {
|
||||
dwnd().getDrawer().drawTriangles();
|
||||
}
|
||||
}
|
||||
|
||||
void gSPCombineMatrices()
|
||||
|
@ -50,13 +52,13 @@ void gSPCombineMatrices()
|
|||
|
||||
void gSPTriangle(s32 v0, s32 v1, s32 v2)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if ((v0 < INDEXMAP_SIZE) && (v1 < INDEXMAP_SIZE) && (v2 < INDEXMAP_SIZE)) {
|
||||
if (render.isClipped(v0, v1, v2))
|
||||
if (drawer.isClipped(v0, v1, v2))
|
||||
return;
|
||||
render.addTriangle(v0, v1, v2);
|
||||
drawer.addTriangle(v0, v1, v2);
|
||||
if (config.frameBufferEmulation.N64DepthCompare != 0)
|
||||
render.drawTriangles();
|
||||
drawer.drawTriangles();
|
||||
}
|
||||
|
||||
frameBufferList().setBufferChanged();
|
||||
|
@ -104,9 +106,9 @@ f32 identityMatrix[4][4] =
|
|||
static void gSPTransformVertex4_default(u32 v, float mtx[4][4])
|
||||
{
|
||||
float x, y, z, w;
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
x = vtx.x;
|
||||
y = vtx.y;
|
||||
z = vtx.z;
|
||||
|
@ -120,10 +122,10 @@ static void gSPTransformVertex4_default(u32 v, float mtx[4][4])
|
|||
|
||||
static void gSPLightVertex4_default(u32 v)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if (!config.generalEmulation.enableHWLighting) {
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
vtx.r = gSP.lights[gSP.numLights].r;
|
||||
vtx.g = gSP.lights[gSP.numLights].g;
|
||||
vtx.b = gSP.lights[gSP.numLights].b;
|
||||
|
@ -143,7 +145,7 @@ static void gSPLightVertex4_default(u32 v)
|
|||
}
|
||||
} else {
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
vtx.HWLight = gSP.numLights;
|
||||
vtx.r = vtx.nx;
|
||||
vtx.g = vtx.ny;
|
||||
|
@ -155,9 +157,9 @@ static void gSPLightVertex4_default(u32 v)
|
|||
static void gSPPointLightVertex4_default(u32 v, float _vPos[4][3])
|
||||
{
|
||||
assert(_vPos != nullptr);
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
float light_intensity = 0.0f;
|
||||
vtx.HWLight = 0;
|
||||
vtx.r = gSP.lights[gSP.numLights].r;
|
||||
|
@ -189,9 +191,9 @@ static void gSPPointLightVertex4_default(u32 v, float _vPos[4][3])
|
|||
|
||||
static void gSPLightVertex4_CBFD(u32 v)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
f32 r = gSP.lights[gSP.numLights].r;
|
||||
f32 g = gSP.lights[gSP.numLights].g;
|
||||
f32 b = gSP.lights[gSP.numLights].b;
|
||||
|
@ -223,9 +225,9 @@ static void gSPLightVertex4_CBFD(u32 v)
|
|||
|
||||
static void gSPPointLightVertex4_CBFD(u32 v, float _vPos[4][3])
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
f32 r = gSP.lights[gSP.numLights].r;
|
||||
f32 g = gSP.lights[gSP.numLights].g;
|
||||
f32 b = gSP.lights[gSP.numLights].b;
|
||||
|
@ -271,11 +273,11 @@ static void gSPPointLightVertex4_CBFD(u32 v, float _vPos[4][3])
|
|||
|
||||
static void gSPBillboardVertex4_default(u32 v)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
int i = 0;
|
||||
SPVertex & vtx0 = render.getVertex(i);
|
||||
SPVertex & vtx0 = drawer.getVertex(i);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
vtx.x += vtx0.x;
|
||||
vtx.y += vtx0.y;
|
||||
vtx.z += vtx0.z;
|
||||
|
@ -285,9 +287,9 @@ static void gSPBillboardVertex4_default(u32 v)
|
|||
|
||||
void gSPClipVertex4(u32 v)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
vtx.clip = 0;
|
||||
if (vtx.x > +vtx.w) vtx.clip |= CLIP_POSX;
|
||||
if (vtx.x < -vtx.w) vtx.clip |= CLIP_NEGX;
|
||||
|
@ -302,11 +304,11 @@ void gSPProcessVertex4(u32 v)
|
|||
if (gSP.changed & CHANGED_MATRIX)
|
||||
gSPCombineMatrices();
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
OGLRender & render = ogl.getRender();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||
float vPos[4][3];
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
vPos[i][0] = vtx.x;
|
||||
vPos[i][1] = vtx.y;
|
||||
vPos[i][2] = vtx.z;
|
||||
|
@ -314,18 +316,18 @@ void gSPProcessVertex4(u32 v)
|
|||
}
|
||||
gSPTransformVertex4(v, gSP.matrix.combined );
|
||||
|
||||
if (ogl.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
vtx.x *= ogl.getAdjustScale();
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
vtx.x *= wnd.getAdjustScale();
|
||||
if (gSP.matrix.projection[3][2] == -1.f)
|
||||
vtx.w *= ogl.getAdjustScale();
|
||||
vtx.w *= wnd.getAdjustScale();
|
||||
}
|
||||
}
|
||||
|
||||
if (gSP.viewport.vscale[0] < 0) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
vtx.x = -vtx.x;
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +343,7 @@ void gSPProcessVertex4(u32 v)
|
|||
|
||||
if (GBI.isTextureGen() && (gSP.geometryMode & G_TEXTURE_GEN) != 0) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
SPVertex & vtx = render.getVertex(v+i);
|
||||
SPVertex & vtx = drawer.getVertex(v+i);
|
||||
f32 fLightDir[3] = {vtx.nx, vtx.ny, vtx.nz};
|
||||
f32 x, y;
|
||||
if (gSP.lookatEnable) {
|
||||
|
@ -366,7 +368,7 @@ void gSPProcessVertex4(u32 v)
|
|||
}
|
||||
} else {
|
||||
for(int i = 0; i < 4; ++i)
|
||||
render.getVertex(v+i).HWLight = 0;
|
||||
drawer.getVertex(v+i).HWLight = 0;
|
||||
}
|
||||
|
||||
gSPClipVertex4(v);
|
||||
|
@ -521,9 +523,9 @@ static void gSPPointLightVertex_CBFD(SPVertex & _vtx, float * /*_vPos*/)
|
|||
|
||||
static void gSPBillboardVertex_default(u32 v, u32 i)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
SPVertex & vtx0 = render.getVertex(i);
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
SPVertex & vtx0 = drawer.getVertex(i);
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
vtx.x += vtx0.x;
|
||||
vtx.y += vtx0.y;
|
||||
vtx.z += vtx0.z;
|
||||
|
@ -532,7 +534,7 @@ static void gSPBillboardVertex_default(u32 v, u32 i)
|
|||
|
||||
void gSPClipVertex(u32 v)
|
||||
{
|
||||
SPVertex & vtx = video().getRender().getVertex(v);
|
||||
SPVertex & vtx = dwnd().getDrawer().getVertex(v);
|
||||
vtx.clip = 0;
|
||||
if (vtx.x > +vtx.w) vtx.clip |= CLIP_POSX;
|
||||
if (vtx.x < -vtx.w) vtx.clip |= CLIP_NEGX;
|
||||
|
@ -546,16 +548,16 @@ void gSPProcessVertex(u32 v)
|
|||
if (gSP.changed & CHANGED_MATRIX)
|
||||
gSPCombineMatrices();
|
||||
|
||||
OGLVideo & ogl = video();
|
||||
OGLRender & render = ogl.getRender();
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
DisplayWindow & wnd = dwnd();
|
||||
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
float vPos[3] = {(float)vtx.x, (float)vtx.y, (float)vtx.z};
|
||||
gSPTransformVertex( &vtx.x, gSP.matrix.combined );
|
||||
|
||||
if (ogl.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
vtx.x *= ogl.getAdjustScale();
|
||||
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
vtx.x *= wnd.getAdjustScale();
|
||||
if (gSP.matrix.projection[3][2] == -1.f)
|
||||
vtx.w *= ogl.getAdjustScale();
|
||||
vtx.w *= wnd.getAdjustScale();
|
||||
}
|
||||
|
||||
if (gSP.viewport.vscale[0] < 0)
|
||||
|
@ -936,14 +938,14 @@ void gSPVertex(u32 a, u32 n, u32 v0)
|
|||
|
||||
Vertex *vertex = (Vertex*)&RDRAM[address];
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if ((n + v0) <= INDEXMAP_SIZE) {
|
||||
unsigned int i = v0;
|
||||
#ifdef __VEC4_OPT
|
||||
for (; i < n - (n%4) + v0; i += 4) {
|
||||
u32 v = i;
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -968,7 +970,7 @@ void gSPVertex(u32 a, u32 n, u32 v0)
|
|||
#endif
|
||||
for (; i < n + v0; ++i) {
|
||||
u32 v = i;
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -1012,14 +1014,14 @@ void gSPCIVertex( u32 a, u32 n, u32 v0 )
|
|||
|
||||
PDVertex *vertex = (PDVertex*)&RDRAM[address];
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if ((n + v0) <= INDEXMAP_SIZE) {
|
||||
unsigned int i = v0;
|
||||
#ifdef __VEC4_OPT
|
||||
for (; i < n - (n%4) + v0; i += 4) {
|
||||
u32 v = i;
|
||||
for(unsigned int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v + j);
|
||||
SPVertex & vtx = drawer.getVertex(v + j);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -1045,7 +1047,7 @@ void gSPCIVertex( u32 a, u32 n, u32 v0 )
|
|||
#endif
|
||||
for(; i < n + v0; ++i) {
|
||||
u32 v = i;
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -1090,14 +1092,14 @@ void gSPDMAVertex( u32 a, u32 n, u32 v0 )
|
|||
gSPUpdateLookatVectors();
|
||||
}
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if ((n + v0) <= INDEXMAP_SIZE) {
|
||||
u32 i = v0;
|
||||
#ifdef __VEC4_OPT
|
||||
for (; i < n - (n%4) + v0; i += 4) {
|
||||
u32 v = i;
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v + j);
|
||||
SPVertex & vtx = drawer.getVertex(v + j);
|
||||
vtx.x = *(s16*)&RDRAM[address ^ 2];
|
||||
vtx.y = *(s16*)&RDRAM[(address + 2) ^ 2];
|
||||
vtx.z = *(s16*)&RDRAM[(address + 4) ^ 2];
|
||||
|
@ -1120,7 +1122,7 @@ void gSPDMAVertex( u32 a, u32 n, u32 v0 )
|
|||
#endif
|
||||
for (; i < n + v0; ++i) {
|
||||
u32 v = i;
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
vtx.x = *(s16*)&RDRAM[address ^ 2];
|
||||
vtx.y = *(s16*)&RDRAM[(address + 2) ^ 2];
|
||||
vtx.z = *(s16*)&RDRAM[(address + 4) ^ 2];
|
||||
|
@ -1163,14 +1165,14 @@ void gSPCBFDVertex( u32 a, u32 n, u32 v0 )
|
|||
|
||||
Vertex *vertex = (Vertex*)&RDRAM[address];
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
if ((n + v0) <= INDEXMAP_SIZE) {
|
||||
unsigned int i = v0;
|
||||
#ifdef __VEC4_OPT
|
||||
for (; i < n - (n%4) + v0; i += 4) {
|
||||
u32 v = i;
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
SPVertex & vtx = render.getVertex(v+j);
|
||||
SPVertex & vtx = drawer.getVertex(v+j);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -1193,7 +1195,7 @@ void gSPCBFDVertex( u32 a, u32 n, u32 v0 )
|
|||
#endif
|
||||
for (; i < n + v0; ++i) {
|
||||
u32 v = i;
|
||||
SPVertex & vtx = render.getVertex(v);
|
||||
SPVertex & vtx = drawer.getVertex(v);
|
||||
vtx.x = vertex->x;
|
||||
vtx.y = vertex->y;
|
||||
vtx.z = vertex->z;
|
||||
|
@ -1284,7 +1286,7 @@ void gSPBranchLessZ( u32 branchdl, u32 vtx, u32 zval )
|
|||
return;
|
||||
}
|
||||
|
||||
SPVertex & v = video().getRender().getVertex(vtx);
|
||||
SPVertex & v = dwnd().getDrawer().getVertex(vtx);
|
||||
const u32 zTest = u32((v.z / v.w) * 1023.0f);
|
||||
if (zTest > 0x03FF || zTest <= zval)
|
||||
RSP.PC[RSP.PCi] = address;
|
||||
|
@ -1308,7 +1310,7 @@ void gSPBranchLessW( u32 branchdl, u32 vtx, u32 wval )
|
|||
return;
|
||||
}
|
||||
|
||||
SPVertex & v = video().getRender().getVertex(vtx);
|
||||
SPVertex & v = dwnd().getDrawer().getVertex(vtx);
|
||||
if (v.w < (float)wval)
|
||||
RSP.PC[RSP.PCi] = address;
|
||||
|
||||
|
@ -1390,11 +1392,11 @@ void gSPDMATriangles( u32 tris, u32 n ){
|
|||
return;
|
||||
}
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(n * 3);
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(n * 3);
|
||||
|
||||
DKRTriangle *triangles = (DKRTriangle*)&RDRAM[address];
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
for (u32 i = 0; i < n; ++i) {
|
||||
int mode = 0;
|
||||
if (!(triangles->flag & 0x40)) {
|
||||
|
@ -1404,8 +1406,8 @@ void gSPDMATriangles( u32 tris, u32 n ){
|
|||
mode |= G_CULL_FRONT;
|
||||
}
|
||||
if ((gSP.geometryMode&G_CULL_BOTH) != mode) {
|
||||
render.drawDMATriangles(pVtx - render.getDMAVerticesData());
|
||||
pVtx = render.getDMAVerticesData();
|
||||
drawer.drawDMATriangles(pVtx - drawer.getDMAVerticesData());
|
||||
pVtx = drawer.getDMAVerticesData();
|
||||
gSP.geometryMode &= ~G_CULL_BOTH;
|
||||
gSP.geometryMode |= mode;
|
||||
gSP.changed |= CHANGED_GEOMETRYMODE;
|
||||
|
@ -1414,25 +1416,25 @@ void gSPDMATriangles( u32 tris, u32 n ){
|
|||
const s32 v0 = triangles->v0;
|
||||
const s32 v1 = triangles->v1;
|
||||
const s32 v2 = triangles->v2;
|
||||
if (render.isClipped(v0, v1, v2)) {
|
||||
if (drawer.isClipped(v0, v1, v2)) {
|
||||
++triangles;
|
||||
continue;
|
||||
}
|
||||
*pVtx = render.getVertex(v0);
|
||||
*pVtx = drawer.getVertex(v0);
|
||||
pVtx->s = _FIXED2FLOAT(triangles->s0, 5);
|
||||
pVtx->t = _FIXED2FLOAT(triangles->t0, 5);
|
||||
++pVtx;
|
||||
*pVtx = render.getVertex(v1);
|
||||
*pVtx = drawer.getVertex(v1);
|
||||
pVtx->s = _FIXED2FLOAT(triangles->s1, 5);
|
||||
pVtx->t = _FIXED2FLOAT(triangles->t1, 5);
|
||||
++pVtx;
|
||||
*pVtx = render.getVertex(v2);
|
||||
*pVtx = drawer.getVertex(v2);
|
||||
pVtx->s = _FIXED2FLOAT(triangles->s2, 5);
|
||||
pVtx->t = _FIXED2FLOAT(triangles->t2, 5);
|
||||
++pVtx;
|
||||
++triangles;
|
||||
}
|
||||
render.drawDMATriangles(pVtx - render.getDMAVerticesData());
|
||||
drawer.drawDMATriangles(pVtx - drawer.getDMAVerticesData());
|
||||
}
|
||||
|
||||
void gSP1Quadrangle( s32 v0, s32 v1, s32 v2, s32 v3 )
|
||||
|
@ -1456,9 +1458,9 @@ bool gSPCullVertices( u32 v0, u32 vn )
|
|||
vn = v;
|
||||
}
|
||||
u32 clip = 0;
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
for (u32 i = v0; i <= vn; ++i) {
|
||||
clip |= (~render.getVertex(i).clip) & CLIP_ALL;
|
||||
clip |= (~drawer.getVertex(i).clip) & CLIP_ALL;
|
||||
if (clip == CLIP_ALL)
|
||||
return false;
|
||||
}
|
||||
|
@ -1582,9 +1584,9 @@ void gSPInsertMatrix( u32 where, u32 num )
|
|||
|
||||
void gSPModifyVertex( u32 _vtx, u32 _where, u32 _val )
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
|
||||
SPVertex & vtx0 = render.getVertex(_vtx);
|
||||
SPVertex & vtx0 = drawer.getVertex(_vtx);
|
||||
switch (_where) {
|
||||
case G_MWO_POINT_RGBA:
|
||||
vtx0.r = _SHIFTR( _val, 24, 8 ) * 0.0039215689f;
|
||||
|
@ -1833,7 +1835,7 @@ void gSPSetOtherMode_L(u32 _length, u32 _shift, u32 _data)
|
|||
|
||||
void gSPLine3D( s32 v0, s32 v1, s32 flag )
|
||||
{
|
||||
video().getRender().drawLine(v0, v1, 1.5f);
|
||||
dwnd().getDrawer().drawLine(v0, v1, 1.5f);
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_UNHANDLED, "gSPLine3D( %i, %i, %i );\n", v0, v1, flag );
|
||||
|
@ -1842,7 +1844,7 @@ void gSPLine3D( s32 v0, s32 v1, s32 flag )
|
|||
|
||||
void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag )
|
||||
{
|
||||
video().getRender().drawLine(v0, v1, 1.5f + wd * 0.5f);
|
||||
dwnd().getDrawer().drawLine(v0, v1, 1.5f + wd * 0.5f);
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_UNHANDLED, "gSPLineW3D( %i, %i, %i, %i );\n", v0, v1, wd, flag );
|
||||
#endif
|
||||
|
@ -2006,9 +2008,9 @@ struct ObjCoordinates
|
|||
static
|
||||
void gSPDrawObjRect(const ObjCoordinates & _coords)
|
||||
{
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
SPVertex & vtx0 = pVtx[0];
|
||||
vtx0.x = _coords.ulx;
|
||||
vtx0.y = _coords.uly;
|
||||
|
@ -2038,7 +2040,7 @@ void gSPDrawObjRect(const ObjCoordinates & _coords)
|
|||
vtx3.s = _coords.lrs;
|
||||
vtx3.t = _coords.lrt;
|
||||
|
||||
render.drawScreenSpaceTriangle(4);
|
||||
drawer.drawScreenSpaceTriangle(4);
|
||||
gDP.colorImage.height = (u32)(max(gDP.colorImage.height, (u32)gDP.scissor.lry));
|
||||
}
|
||||
|
||||
|
@ -2151,10 +2153,10 @@ void _copyDepthBuffer()
|
|||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pTmpBuffer->m_FBO);
|
||||
pCopyBufferDepth->setDepthAttachment(pTmpBuffer->m_FBO, GL_READ_FRAMEBUFFER);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbList.getCurrent()->m_FBO);
|
||||
OGLVideo & ogl = video();
|
||||
DisplayWindow & wnd = dwnd();
|
||||
glBlitFramebuffer(
|
||||
0, 0, ogl.getWidth(), ogl.getHeight(),
|
||||
0, 0, ogl.getWidth(), ogl.getHeight(),
|
||||
0, 0, wnd.getWidth(), wnd.getHeight(),
|
||||
0, 0, wnd.getWidth(), wnd.getHeight(),
|
||||
GL_DEPTH_BUFFER_BIT, GL_NEAREST
|
||||
);
|
||||
// Restore objects
|
||||
|
@ -2280,9 +2282,9 @@ void gSPObjSprite(u32 _sp)
|
|||
}
|
||||
const float z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
|
||||
SPVertex & vtx0 = pVtx[0];
|
||||
vtx0.x = gSP.objMatrix.A * ulx + gSP.objMatrix.B * uly + gSP.objMatrix.X;
|
||||
|
@ -2313,7 +2315,7 @@ void gSPObjSprite(u32 _sp)
|
|||
vtx3.s = lrs;
|
||||
vtx3.t = lrt;
|
||||
|
||||
render.drawScreenSpaceTriangle(4);
|
||||
drawer.drawScreenSpaceTriangle(4);
|
||||
|
||||
frameBufferList().setBufferChanged();
|
||||
gDP.colorImage.height = (u32)(max( gDP.colorImage.height, (u32)gDP.scissor.lry ));
|
||||
|
@ -2425,9 +2427,9 @@ void gSPSprite2DBase(u32 _base)
|
|||
}
|
||||
*/
|
||||
|
||||
OGLRender & render = video().getRender();
|
||||
render.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = render.getDMAVerticesData();
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.setDMAVerticesSize(4);
|
||||
SPVertex * pVtx = drawer.getDMAVerticesData();
|
||||
|
||||
SPVertex & vtx0 = pVtx[0];
|
||||
vtx0.x = ulx;
|
||||
|
@ -2459,7 +2461,7 @@ void gSPSprite2DBase(u32 _base)
|
|||
vtx3.t = lrt;
|
||||
|
||||
if (pSprite->stride > 0)
|
||||
render.drawScreenSpaceTriangle(4);
|
||||
drawer.drawScreenSpaceTriangle(4);
|
||||
} while (RSP.nextCmd == 0xBD || RSP.nextCmd == 0xBE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "GLideN64_mupenplus.h"
|
||||
#include "../PluginAPI.h"
|
||||
#include "../GLideN64.h"
|
||||
#include "../OpenGL.h"
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
#ifdef OS_WINDOWS
|
||||
#define DLSYM(a, b) GetProcAddress(a, b)
|
||||
|
@ -123,10 +123,10 @@ void PluginAPI::SetRenderingCallback(void (*callback)(int))
|
|||
|
||||
void PluginAPI::ResizeVideoOutput(int _Width, int _Height)
|
||||
{
|
||||
video().setWindowSize(_Width, _Height);
|
||||
dwnd().setWindowSize(_Width, _Height);
|
||||
}
|
||||
|
||||
void PluginAPI::ReadScreen2(void * _dest, int * _width, int * _height, int _front)
|
||||
{
|
||||
video().readScreen2(_dest, _width, _height, _front);
|
||||
dwnd().readScreen2(_dest, _width, _height, _front);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
#include "../Config.h"
|
||||
#include "../RSP.h"
|
||||
#include "../PluginAPI.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLideNUI/GLideNUI.h"
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
|
||||
Config config;
|
||||
|
||||
|
@ -18,7 +19,7 @@ void Config_DoConfig(/*HWND hParent*/)
|
|||
if (config.generalEmulation.enableCustomSettings != 0)
|
||||
LoadCustomRomSettings(strIniFolderPath, RSP.romname);
|
||||
if (bRestart)
|
||||
video().restart();
|
||||
dwnd().restart();
|
||||
ConfigOpen = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "../PluginAPI.h"
|
||||
#include "../GLideN64.h"
|
||||
#include "../GLideNUI/GLideNUI.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../Config.h"
|
||||
#include "../Revision.h"
|
||||
#include <DisplayWindow.h>
|
||||
|
||||
void PluginAPI::DllAbout(/*HWND _hParent*/)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ void PluginAPI::DllAbout(/*HWND _hParent*/)
|
|||
|
||||
void PluginAPI::CaptureScreen(char * _Directory)
|
||||
{
|
||||
video().setCaptureScreen(_Directory);
|
||||
dwnd().setCaptureScreen(_Directory);
|
||||
}
|
||||
|
||||
void PluginAPI::DllConfig(HWND _hParent)
|
||||
|
|
Loading…
Reference in New Issue
Block a user