mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Do not fail if indices of barycoords attributes are greater or equal to max vertex attributes.
This commit is contained in:
parent
2f8372c113
commit
ca68dc3675
|
@ -3019,13 +3019,13 @@ CombinerProgramBuilder::CombinerProgramBuilder(const opengl::GLInfo & _glinfo, o
|
|||
, m_shaderCoverage(new ShaderCoverage())
|
||||
, m_useProgram(_useProgram)
|
||||
, m_combinerOptionsBits(graphics::CombinerProgram::getShaderCombinerOptionsBits())
|
||||
, m_useCoverage(_glinfo.coverage && config.generalEmulation.enableCoverage != 0)
|
||||
{
|
||||
m_vertexShaderRect = _createVertexShader(m_vertexHeader.get(), m_vertexRect.get(), m_vertexEnd.get());
|
||||
m_vertexShaderTriangle = _createVertexShader(m_vertexHeader.get(), m_vertexTriangle.get(), m_vertexEnd.get());
|
||||
m_vertexShaderTexturedRect = _createVertexShader(m_vertexHeader.get(), m_vertexTexturedRect.get(), m_vertexEnd.get());
|
||||
m_vertexShaderTexturedTriangle = _createVertexShader(m_vertexHeader.get(), m_vertexTexturedTriangle.get(), m_vertexEnd.get());
|
||||
m_uniformFactory.reset(new CombinerProgramUniformFactory(_glinfo));
|
||||
m_useCoverage = (config.generalEmulation.enableCoverage != 0) && (_glinfo.dual_source_blending || _glinfo.ext_fetch || _glinfo.ext_fetch_arm);
|
||||
}
|
||||
|
||||
CombinerProgramBuilder::~CombinerProgramBuilder()
|
||||
|
|
|
@ -7,9 +7,14 @@ using namespace glsl;
|
|||
|
||||
void Utils::locateAttributes(GLuint _program, bool _rect, bool _textures)
|
||||
{
|
||||
static GLint maxVertexAttribs = 0;
|
||||
if (maxVertexAttribs == 0)
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
|
||||
|
||||
if (_rect) {
|
||||
glBindAttribLocation(_program, opengl::rectAttrib::position, "aRectPosition");
|
||||
glBindAttribLocation(_program, opengl::rectAttrib::barycoords, "aBaryCoords");
|
||||
if (opengl::rectAttrib::barycoords < static_cast<u32>(maxVertexAttribs))
|
||||
glBindAttribLocation(_program, opengl::rectAttrib::barycoords, "aBaryCoords");
|
||||
if (_textures) {
|
||||
glBindAttribLocation(_program, opengl::rectAttrib::texcoord0, "aTexCoord0");
|
||||
glBindAttribLocation(_program, opengl::rectAttrib::texcoord1, "aTexCoord1");
|
||||
|
@ -21,7 +26,8 @@ void Utils::locateAttributes(GLuint _program, bool _rect, bool _textures)
|
|||
glBindAttribLocation(_program, opengl::triangleAttrib::color, "aColor");
|
||||
glBindAttribLocation(_program, opengl::triangleAttrib::numlights, "aNumLights");
|
||||
glBindAttribLocation(_program, opengl::triangleAttrib::modify, "aModify");
|
||||
glBindAttribLocation(_program, opengl::triangleAttrib::barycoords, "aBaryCoords");
|
||||
if (opengl::triangleAttrib::barycoords < static_cast<u32>(maxVertexAttribs))
|
||||
glBindAttribLocation(_program, opengl::triangleAttrib::barycoords, "aBaryCoords");
|
||||
if (_textures)
|
||||
glBindAttribLocation(_program, opengl::triangleAttrib::texcoord, "aTexCoord");
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ namespace opengl {
|
|||
const GLuint texcoord = 2U;
|
||||
const GLuint numlights = 3U;
|
||||
const GLuint modify = 4U;
|
||||
const GLuint barycoords = 5U;
|
||||
const GLuint barycoords = 8U;
|
||||
}
|
||||
|
||||
// Rect attributes
|
||||
namespace rectAttrib {
|
||||
const GLuint position = 6U;
|
||||
const GLuint texcoord0 = 7U;
|
||||
const GLuint texcoord1 = 8U;
|
||||
const GLuint position = 5U;
|
||||
const GLuint texcoord0 = 6U;
|
||||
const GLuint texcoord1 = 7U;
|
||||
const GLuint barycoords = 9U;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ BufferedDrawer::BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray *
|
|||
glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, x)));
|
||||
glVertexAttribPointer(rectAttrib::texcoord0, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, s0)));
|
||||
glVertexAttribPointer(rectAttrib::texcoord1, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, s1)));
|
||||
glVertexAttribPointer(rectAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, bc0)));
|
||||
if (_glinfo.coverage)
|
||||
glVertexAttribPointer(rectAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, bc0)));
|
||||
|
||||
/* Init buffers for triangles */
|
||||
glGenVertexArrays(1, &m_trisBuffers.vao);
|
||||
|
@ -45,12 +46,14 @@ BufferedDrawer::BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray *
|
|||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, true);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, true);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::numlights, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, true);
|
||||
glVertexAttribPointer(triangleAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, x)));
|
||||
glVertexAttribPointer(triangleAttrib::color, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, r)));
|
||||
glVertexAttribPointer(triangleAttrib::texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, s)));
|
||||
glVertexAttribPointer(triangleAttrib::modify, 4, GL_BYTE, GL_TRUE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, modify)));
|
||||
glVertexAttribPointer(triangleAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, bc0)));
|
||||
if (_glinfo.coverage) {
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, true);
|
||||
glVertexAttribPointer(triangleAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, bc0)));
|
||||
}
|
||||
}
|
||||
|
||||
void BufferedDrawer::_initBuffer(Buffer & _buffer, GLuint _bufSize)
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace opengl {
|
|||
f32 x, y, z, w;
|
||||
f32 r, g, b, a;
|
||||
f32 s, t;
|
||||
u32 modify;
|
||||
f32 bc0, bc1;
|
||||
u32 modify;
|
||||
};
|
||||
|
||||
void _initBuffer(Buffer & _buffer, GLuint _bufSize);
|
||||
|
|
|
@ -198,6 +198,13 @@ void GLInfo::init() {
|
|||
}
|
||||
}
|
||||
|
||||
coverage = dual_source_blending || ext_fetch || ext_fetch_arm;
|
||||
if (coverage) {
|
||||
GLint maxVertexAttribs = 0;
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
|
||||
coverage = maxVertexAttribs >= 10;
|
||||
}
|
||||
|
||||
#ifdef EGL
|
||||
if (isGLESX)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ struct GLInfo {
|
|||
bool eglImage = false;
|
||||
bool eglImageFramebuffer = false;
|
||||
bool dual_source_blending = false;
|
||||
bool coverage = false;
|
||||
Renderer renderer = Renderer::Other;
|
||||
|
||||
void init();
|
||||
|
|
|
@ -9,18 +9,22 @@ using namespace opengl;
|
|||
UnbufferedDrawer::UnbufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray * _cachedAttribArray)
|
||||
: m_glInfo(_glinfo)
|
||||
, m_cachedAttribArray(_cachedAttribArray)
|
||||
, m_useCoverage(_glinfo.coverage)
|
||||
{
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::position, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::color, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::numlights, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
|
||||
|
||||
if (m_useCoverage) {
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
|
||||
}
|
||||
|
||||
m_attribsData.fill(nullptr);
|
||||
}
|
||||
|
@ -71,7 +75,7 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame
|
|||
glVertexAttribPointer(triangleAttrib::modify, 4, GL_BYTE, GL_FALSE, sizeof(SPVertex), ptr);
|
||||
}
|
||||
|
||||
{
|
||||
if (m_useCoverage) {
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, true);
|
||||
const void * ptr = &_params.vertices->bc0;
|
||||
if (_updateAttribPointer(triangleAttrib::barycoords, ptr))
|
||||
|
@ -84,7 +88,8 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame
|
|||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
|
||||
if (m_useCoverage)
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
|
||||
|
||||
if (config.frameBufferEmulation.N64DepthCompare != Config::dcCompatible) {
|
||||
if (_params.elements == nullptr) {
|
||||
|
@ -143,7 +148,7 @@ void UnbufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _
|
|||
} else
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
|
||||
|
||||
{
|
||||
if (m_useCoverage) {
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, true);
|
||||
const void * ptr = &_params.vertices->bc0;
|
||||
if (_updateAttribPointer(rectAttrib::barycoords, ptr))
|
||||
|
@ -154,7 +159,8 @@ void UnbufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _
|
|||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::color, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
if (m_useCoverage)
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
|
||||
glDrawArrays(GLenum(_params.mode), 0, _params.verticesCount);
|
||||
}
|
||||
|
@ -177,7 +183,8 @@ void UnbufferedDrawer::drawLine(f32 _width, SPVertex * _vertices)
|
|||
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
if (m_useCoverage)
|
||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
|
||||
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
|
||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace opengl {
|
|||
const GLInfo & m_glInfo;
|
||||
CachedVertexAttribArray * m_cachedAttribArray;
|
||||
std::array<const void*, MaxAttribIndex> m_attribsData;
|
||||
bool m_useCoverage = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user