Permalink
Browse files

video-gliden64: Update to commit f3677db.

gonetz/GLideN64@f3677db

* f3677db Fix copy to RDRAM for native resolution factors above 1.
* 85101a5 Yet another fix for gDPLoadBlock line calculation.
* dc23dc6 don't write to the logfile if it doesn't open correctly (eg permissions) #930
* d1129ff Fix texture coordinates calculation in GLES2 vertex shader
* 8d3e6ef Revert "Reset TLUT mode to NONE after each frame."
* 7875b60 Detect microcodes, where texture perspective correction is always enabled.
* cc5dc00 Use current TLUT mode in texture CRC.
* 8488ebc Fix texture coordinates calculation in vertex shader when TexturePersp disabled.
* 0fb603d Clear gSP.status on dlist start.
* 5fc8239 Save correct ConfigOptionsBitSet to shader storage header.
* d8f8f58 Fix texture clamp size calculation during texture load.
* f0b76ae Fix custom windowed mode, issue #917
* cf8d597 Correct hack for Blast Corps.
* a5e7bc5 Add blend mode for Bomberman 64: the Second Attack
* 3c675b1 Do not draw Sprite2D when sprite->stride <= 0.
* bcde07a Don't skip buffer height calculation in gDPFillRectangle.
* 769e474 Set texrect vertex alpha to 1 if alpha combiner uses only shade alpha.
* fedc15f Revert "Set texrect vertex alpha to 1 for Pokemon Stadium 2."
* 3cfb377 Fixed scissor in FrameBufferList::renderBuffer when AA enabled.
* ea62a77 Force resolve multisampled buffer in FrameBufferList::renderBuffer.
* 325082b Don't call gDPFullSync() when config window is open. gDPFullSync() calls buffers read, which can be broken when settings changed.
* 096d2f7 Fix screenshot capture from antialased buffer, issue #905
* 0546663 Correct main bufer height calculation again: fix regression caused by commit 3215a8ad5d95
* 04b1f3f Correct gDPLoadBlock line calculation again: fixed regression caused by commit f6be5fd39
* 80c954e Move modify_vtx transformations to vertex shader.
* 7549e04 Move calculations from drawLLETriangle to vertex shader.
* 16f5bfa Use correct screen scale when native resolution used.
* f6be5fd Fix bug with line calculation in gDPLoadBlock.
* 2a56af9 Always update texture for texrect.
* f59518f Correct texrectVertexFullAlpha hack description
* 54e0c53 Set texrect vertex alpha to 1 for Pokemon Stadium 2. Texrect vertex alpha was set to 1 for all games in d506d6134d commit as fix for issue #721. It causes regression in Duke Nukem 64, issue #906, so I made separate hack and enable it for PS2.
  • Loading branch information...
1 parent cb5e0bc commit d9c140fbb48f39b40ff41d63fb6590867e0b483c @fzurita fzurita committed Mar 25, 2016
@@ -366,7 +366,7 @@ Storage format:
uint32 - number of shaders
shaders in binary form
*/
-static const u32 ShaderStorageFormatVersion = 0x04U; // Shaders changed after rev. b7369e
+static const u32 ShaderStorageFormatVersion = 0x06U;
void CombinerInfo::_saveShadersStorage() const
{
if (m_shadersLoaded >= m_combiners.size())
@@ -387,8 +387,7 @@ void CombinerInfo::_saveShadersStorage() const
fout.write((char*)&ShaderStorageFormatVersion, sizeof(ShaderStorageFormatVersion));
- const u32 optionsSet = _getConfigOptionsBitSet();
- fout.write((char*)&optionsSet, sizeof(optionsSet));
+ fout.write((char*)&m_configOptionsBitSet, sizeof(m_configOptionsBitSet));
const char * strRenderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
u32 len = strlen(strRenderer);
@@ -412,6 +411,7 @@ bool CombinerInfo::_loadShadersStorage()
{
wchar_t fileName[PLUGIN_PATH_SIZE];
getStorageFileName(fileName);
+ m_configOptionsBitSet = _getConfigOptionsBitSet();
#ifdef OS_WINDOWS
std::ifstream fin(fileName, std::ofstream::binary);
@@ -431,7 +431,7 @@ bool CombinerInfo::_loadShadersStorage()
u32 optionsSet;
fin.read((char*)&optionsSet, sizeof(optionsSet));
- if (optionsSet != _getConfigOptionsBitSet())
+ if (optionsSet != m_configOptionsBitSet)
return false;
const char * strRenderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
@@ -143,7 +143,12 @@ class CombinerInfo
void updateParameters(OGLRender::RENDER_STATE _renderState);
private:
- CombinerInfo() : m_bChanged(false), m_bShaderCacheSupported(false), m_shadersLoaded(0), m_pCurrent(NULL) {}
+ CombinerInfo()
+ : m_bChanged(false)
+ , m_bShaderCacheSupported(false)
+ , m_shadersLoaded(0)
+ , m_configOptionsBitSet(0)
+ , m_pCurrent(NULL) {}
CombinerInfo(const CombinerInfo &);
void _saveShadersStorage() const;
@@ -154,6 +159,7 @@ class CombinerInfo
bool m_bChanged;
bool m_bShaderCacheSupported;
u32 m_shadersLoaded;
+ u32 m_configOptionsBitSet;
ShaderCombiner * m_pCurrent;
typedef std::map<u64, ShaderCombiner *> Combiners;
@@ -152,7 +152,6 @@ struct Config
#define hack_rectDepthBufferCopyCBFD (1<<10) //Copy depth buffer only when game need it. Optimized for CBFD
#define hack_skipVIChangeCheck (1<<11) //Don't reset FBO when VI parameters changed. Zelda MM
#define hack_ZeldaCamera (1<<12) //Special hack to detect and process Zelda MM camera.
-#define hack_texrectVertexFullAlpha (1<<13) //Set texrect vertex alpha to 1
extern Config config;
@@ -391,10 +391,10 @@ bool FrameBuffer::isValid() const
return true; // No data to decide
}
-void FrameBuffer::resolveMultisampledTexture()
+void FrameBuffer::resolveMultisampledTexture(bool _bForce)
{
#ifdef GL_MULTISAMPLING_SUPPORT
- if (m_resolved)
+ if (m_resolved && !_bForce)
return;
glScissor(0, 0, m_pTexture->realWidth, m_pTexture->realHeight);
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
@@ -538,9 +538,9 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
if (m_pCurrent != NULL) {
// Correct buffer's end address
if (!m_pCurrent->isAuxiliary()) {
- if (gDP.colorImage.height != 0)
+ if (gDP.colorImage.height > 200)
m_prevColorImageHeight = gDP.colorImage.height;
- else
+ else if (gDP.colorImage.height == 0)
gDP.colorImage.height = m_prevColorImageHeight;
gDP.colorImage.height = min(gDP.colorImage.height, VI.height);
m_pCurrent->m_endAddress = min(RDRAMSize, m_pCurrent->m_startAddress + (((m_pCurrent->m_width * gDP.colorImage.height) << m_pCurrent->m_size >> 1) - 1));
@@ -838,8 +838,6 @@ void FrameBufferList::renderBuffer(u32 _address)
render.updateScissor(pBuffer);
PostProcessor::get().doGammaCorrection(pBuffer);
PostProcessor::get().doBlur(pBuffer);
- // glDisable(GL_SCISSOR_TEST) does not affect glBlitFramebuffer, at least on AMD
- glScissor(0, 0, ogl.getScreenWidth(), ogl.getScreenHeight() + ogl.getHeightOffset());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
//glDrawBuffer( GL_BACK );
float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
@@ -850,7 +848,7 @@ void FrameBufferList::renderBuffer(u32 _address)
if (X0 > 0 || dstPartHeight > 0 ||
(srcCoord[2] - srcCoord[0]) != (dstCoord[2] - dstCoord[0]) ||
(srcCoord[3] - srcCoord[1]) != (dstCoord[3] - dstCoord[1])) {
- pBuffer->resolveMultisampledTexture();
+ pBuffer->resolveMultisampledTexture(true);
glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_resolveFBO);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
} else {
@@ -860,6 +858,9 @@ void FrameBufferList::renderBuffer(u32 _address)
} else
glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_FBO);
+ // glDisable(GL_SCISSOR_TEST) does not affect glBlitFramebuffer, at least on AMD
+ glScissor(0, 0, ogl.getScreenWidth(), ogl.getScreenHeight() + ogl.getHeightOffset());
+
glBlitFramebuffer(
srcCoord[0], srcCoord[1], srcCoord[2], srcCoord[3],
dstCoord[0], dstCoord[1], dstCoord[2], dstCoord[3],
@@ -1130,15 +1131,22 @@ bool FrameBufferToRDRAM::_prepareCopy(u32 _startAddress)
if (m_pCurFrameBuffer->m_scaleX > 1.0f) {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
glScissor(0, 0, m_pCurFrameBuffer->m_pTexture->realWidth, m_pCurFrameBuffer->m_pTexture->realHeight);
- const u32 screenWidth = ogl.getWidth();
u32 x0 = 0;
- u32 width = screenWidth;
- if (ogl.isAdjustScreen()) {
- width = static_cast<u32>(screenWidth*ogl.getAdjustScale());
- x0 = (screenWidth - width) / 2;
+ u32 width, height;
+ if (config.frameBufferEmulation.nativeResFactor == 0) {
+ height = ogl.getHeight();
+ const u32 screenWidth = ogl.getWidth();
+ width = screenWidth;
+ if (ogl.isAdjustScreen()) {
+ width = static_cast<u32>(screenWidth*ogl.getAdjustScale());
+ x0 = (screenWidth - width) / 2;
+ }
+ } else {
+ width = m_pCurFrameBuffer->m_pTexture->realWidth;
+ height = m_pCurFrameBuffer->m_pTexture->realHeight;
}
glBlitFramebuffer(
- x0, 0, x0 + width, ogl.getHeight(),
+ x0, 0, x0 + width, height,
0, 0, VI.width, VI.height,
GL_COLOR_BUFFER_BIT, GL_NEAREST
);
@@ -18,7 +18,7 @@ struct FrameBuffer
~FrameBuffer();
void init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u16 _width, u16 _height, bool _cfb);
void reinit(u16 _height);
- void resolveMultisampledTexture();
+ void resolveMultisampledTexture(bool _bForce = false);
CachedTexture * getTexture();
void copyRdram();
bool isValid() const;
@@ -236,6 +236,7 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
current.dataSize = uc_dsize;
current.NoN = false;
current.textureGen = true;
+ current.texturePersp = true;
current.branchLessZ = true;
current.type = NONE;
@@ -283,6 +284,8 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
current.textureGen = false;
else if (strncmp(&uc_str[14], "F3DZ", 4) == 0)
current.branchLessZ = false;
+ else if (strncmp(&uc_str[14], "F3DLP.Rej", 9) == 0)
+ current.texturePersp = false;
}
else if (strncmp( &uc_str[14], "L3D", 3 ) == 0) {
u32 t = 22;
@@ -299,6 +302,7 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
type = S2DEX;
else if (uc_str[t] == '2')
type = S2DEX2;
+ current.texturePersp = false;
}
else if (strncmp(&uc_str[14], "ZSortp", 6) == 0) {
type = ZSortp;
@@ -679,6 +679,7 @@ struct MicrocodeInfo
u32 crc;
bool NoN;
bool textureGen;
+ bool texturePersp;
bool branchLessZ;
};
@@ -695,6 +696,7 @@ struct GBIInfo
bool isHWLSupported() const;
bool isNoN() const { return m_pCurrent != NULL ? m_pCurrent->NoN : false; }
bool isTextureGen() const { return m_pCurrent != NULL ? m_pCurrent->textureGen: true; }
+ bool isTexturePersp() const { return m_pCurrent != NULL ? m_pCurrent->texturePersp: true; }
bool isBranchLessZ() const { return m_pCurrent != NULL ? m_pCurrent->branchLessZ : true; }
private:
@@ -256,6 +256,7 @@ void ShaderCombiner::_locateUniforms() {
LocateUniform(uDepthImage);
LocateUniform(uFogMode);
LocateUniform(uFogUsage);
+ LocateUniform(uScreenCoordsScale);
LocateUniform(uAlphaCompareMode);
LocateUniform(uCvgXAlpha);
LocateUniform(uAlphaCvgSel);
@@ -290,6 +291,7 @@ void ShaderCombiner::_locate_attributes() const {
glBindAttribLocation(m_program, SC_TEXCOORD0, "aTexCoord0");
glBindAttribLocation(m_program, SC_TEXCOORD1, "aTexCoord1");
glBindAttribLocation(m_program, SC_NUMLIGHTS, "aNumLights");
+ glBindAttribLocation(m_program, SC_MODIFY, "aModify");
}
void ShaderCombiner::update(bool _bForce) {
@@ -311,13 +313,22 @@ void ShaderCombiner::update(bool _bForce) {
updateTextureInfo(_bForce);
updateAlphaTestInfo(_bForce);
updateDepthInfo(_bForce);
+ updateScreenCoordsScale(_bForce);
}
void ShaderCombiner::updateRenderState(bool _bForce)
{
m_uniforms.uRenderState.set(video().getRender().getRenderState(), _bForce);
}
+void ShaderCombiner::updateScreenCoordsScale(bool _bForce)
+{
+ FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
+ const float scaleX = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_width : VI.rwidth;
+ const float scaleY = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_height : VI.rheight;
+ m_uniforms.uScreenCoordsScale.set(2.0f*scaleX, -2.0f*scaleY, _bForce);
+}
+
void ShaderCombiner::updateFogMode(bool _bForce)
{
const u32 blender = (gDP.otherMode.l >> 16);
@@ -14,6 +14,7 @@ SHADER_VERSION
"IN highp vec2 aTexCoord0; \n"
"IN highp vec2 aTexCoord1; \n"
"IN lowp float aNumLights; \n"
+"IN highp vec4 aModify; \n"
" \n"
"uniform int uRenderState; \n"
"uniform int uTexturePersp; \n"
@@ -22,13 +23,14 @@ SHADER_VERSION
"uniform lowp int uFogUsage; \n"
"uniform lowp float uFogAlpha; \n"
"uniform mediump vec2 uFogScale; \n"
+"uniform mediump vec2 uScreenCoordsScale; \n"
" \n"
-"uniform mediump vec2 uTexScale; \n"
-"uniform mediump vec2 uTexOffset[2]; \n"
-"uniform mediump vec2 uCacheScale[2]; \n"
-"uniform mediump vec2 uCacheOffset[2]; \n"
-"uniform mediump vec2 uCacheShiftScale[2]; \n"
-"uniform lowp ivec2 uCacheFrameBuffer; \n"
+"uniform mediump vec2 uTexScale; \n"
+"uniform mediump vec2 uTexOffset[2]; \n"
+"uniform mediump vec2 uCacheScale[2]; \n"
+"uniform mediump vec2 uCacheOffset[2]; \n"
+"uniform mediump vec2 uCacheShiftScale[2]; \n"
+"uniform lowp ivec2 uCacheFrameBuffer; \n"
"OUT lowp vec4 vShadeColor; \n"
"OUT mediump vec2 vTexCoord0; \n"
"OUT mediump vec2 vTexCoord1; \n"
@@ -50,14 +52,24 @@ SHADER_VERSION
" gl_Position = aPosition; \n"
" vFogFragCoord = 0.0; \n"
" vShadeColor = aColor; \n"
-" if (uRenderState == 1) { \n"
+" if (uRenderState < 3) { \n"
" vec2 texCoord = aTexCoord0; \n"
" texCoord *= uTexScale; \n"
-" if (uTexturePersp == 0) texCoord *= 0.5; \n"
+" if (uTexturePersp == 0 && aModify[2] == 0.0) texCoord *= 0.5;\n"
" vTexCoord0 = calcTexCoord(texCoord, 0); \n"
" vTexCoord1 = calcTexCoord(texCoord, 1); \n"
" vLodTexCoord = texCoord * uCacheShiftScale[0]; \n"
" vNumLights = aNumLights; \n"
+" if (aModify != vec4(0.0)) { \n"
+" if (aModify[0] != 0.0) { \n"
+" gl_Position.xy = gl_Position.xy * uScreenCoordsScale + vec2(-1.0, 1.0); \n"
+" gl_Position.xy *= gl_Position.w; \n"
+" } \n"
+" if (aModify[1] != 0.0) \n"
+" gl_Position.z *= gl_Position.w; \n"
+" if (aModify[3] != 0.0) \n"
+" vNumLights = 0.0; \n"
+" } \n"
" if (uFogMode == 0) { \n"
" if (aPosition.z < -aPosition.w) \n"
" vFogFragCoord = -uFogScale.s + uFogScale.t; \n"
@@ -96,13 +108,15 @@ SHADER_VERSION
"IN highp vec4 aPosition; \n"
"IN lowp vec4 aColor; \n"
"IN lowp float aNumLights; \n"
+"IN highp vec4 aModify; \n"
" \n"
"uniform int uRenderState; \n"
" \n"
"uniform int uFogMode; \n"
"uniform lowp int uFogUsage; \n"
"uniform lowp float uFogAlpha; \n"
"uniform mediump vec2 uFogScale; \n"
+"uniform mediump vec2 uScreenCoordsScale;\n"
" \n"
"OUT lowp vec4 vShadeColor; \n"
"OUT lowp float vNumLights; \n"
@@ -113,8 +127,18 @@ SHADER_VERSION
" gl_Position = aPosition; \n"
" vFogFragCoord = 0.0; \n"
" vShadeColor = aColor; \n"
-" if (uRenderState == 1) { \n"
+" if (uRenderState < 3) { \n"
" vNumLights = aNumLights; \n"
+" if (aModify != vec4(0.0)) { \n"
+" if (aModify[0] != 0.0) { \n"
+" gl_Position.xy = gl_Position.xy * uScreenCoordsScale + vec2(-1.0, 1.0); \n"
+" gl_Position.xy *= gl_Position.w; \n"
+" } \n"
+" if (aModify[1] != 0.0) \n"
+" gl_Position.z *= gl_Position.w; \n"
+" if (aModify[3] != 0.0) \n"
+" vNumLights = 0.0; \n"
+" } \n"
" if (uFogMode == 0) { \n"
" if (aPosition.z < -aPosition.w) \n"
" vFogFragCoord = -uFogScale.s + uFogScale.t; \n"
@@ -21,6 +21,7 @@ class ShaderCombiner {
void updateAlphaTestInfo(bool _bForce = false);
void updateTextureInfo(bool _bForce = false);
void updateRenderState(bool _bForce = false);
+ void updateScreenCoordsScale(bool _bForce = false);
u64 getMux() const {return m_combine.mux;}
@@ -101,7 +102,7 @@ class ShaderCombiner {
fUniform uFogAlpha, uMinLod, uDeltaZ, uAlphaTestValue, uMSAAScale;
- fv2Uniform uScreenScale, uDepthScale, uFogScale;
+ fv2Uniform uScreenScale, uDepthScale, uFogScale, uScreenCoordsScale;
iv2Uniform uMSTexEnabled, uFbMonochrome, uFbFixedAlpha;
};
@@ -68,10 +68,13 @@ void ConfigDialog::_init()
{
// Video settings
QStringList windowedModesList;
- int windowedModesCurrent = numWindowedModes - 1;
- for (int i = 0; i < numWindowedModes - 1; ++i) {
+ const int windowedModesCustom = numWindowedModes - 1;
+ int windowedModesCurrent = windowedModesCustom;
+ for (int i = 0; i < numWindowedModes; ++i) {
windowedModesList.append(WindowedModes[i].description);
- if (WindowedModes[i].width == config.video.windowedWidth && WindowedModes[i].height == config.video.windowedHeight)
+ if (i != windowedModesCustom &&
+ WindowedModes[i].width == config.video.windowedWidth &&
+ WindowedModes[i].height == config.video.windowedHeight)
windowedModesCurrent = i;
}
ui->windowedResolutionComboBox->insertItems(0, windowedModesList);
@@ -27,6 +27,8 @@ inline void LOG( u16 type, const char * format, ... ) {
if (type > LOG_LEVEL)
return;
FILE *dumpFile = fopen( "gliden64.log", "a+" );
+ if (dumpFile == NULL)
+ return;
va_list va;
va_start( va, format );
vfprintf( dumpFile, format, va );
Oops, something went wrong.

0 comments on commit d9c140f

Please sign in to comment.