mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Replace rectAttrib::color by uniform.
This commit is contained in:
parent
cf8cc76ff9
commit
eebdd32932
|
@ -244,7 +244,6 @@ namespace graphics {
|
||||||
{
|
{
|
||||||
DrawModeParam mode;
|
DrawModeParam mode;
|
||||||
u32 verticesCount = 0;
|
u32 verticesCount = 0;
|
||||||
std::array<f32, 4> rectColor;
|
|
||||||
RectVertex * vertices = nullptr;
|
RectVertex * vertices = nullptr;
|
||||||
const CombinerProgram * combiner = nullptr;
|
const CombinerProgram * combiner = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -355,17 +355,17 @@ public:
|
||||||
{
|
{
|
||||||
m_part =
|
m_part =
|
||||||
"IN highp vec4 aRectPosition; \n"
|
"IN highp vec4 aRectPosition; \n"
|
||||||
"IN lowp vec4 aRectColor; \n"
|
|
||||||
"IN highp vec2 aTexCoord0; \n"
|
"IN highp vec2 aTexCoord0; \n"
|
||||||
"IN highp vec2 aTexCoord1; \n"
|
"IN highp vec2 aTexCoord1; \n"
|
||||||
" \n"
|
" \n"
|
||||||
"OUT lowp vec4 vShadeColor; \n"
|
"OUT lowp vec4 vShadeColor; \n"
|
||||||
"OUT mediump vec2 vTexCoord0; \n"
|
"OUT mediump vec2 vTexCoord0; \n"
|
||||||
"OUT mediump vec2 vTexCoord1; \n"
|
"OUT mediump vec2 vTexCoord1; \n"
|
||||||
|
"uniform lowp vec4 uRectColor; \n"
|
||||||
"void main() \n"
|
"void main() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" gl_Position = aRectPosition; \n"
|
" gl_Position = aRectPosition; \n"
|
||||||
" vShadeColor = aRectColor; \n"
|
" vShadeColor = uRectColor; \n"
|
||||||
" vTexCoord0 = aTexCoord0; \n"
|
" vTexCoord0 = aTexCoord0; \n"
|
||||||
" vTexCoord1 = aTexCoord1; \n"
|
" vTexCoord1 = aTexCoord1; \n"
|
||||||
;
|
;
|
||||||
|
@ -387,13 +387,13 @@ public:
|
||||||
{
|
{
|
||||||
m_part =
|
m_part =
|
||||||
"IN highp vec4 aRectPosition; \n"
|
"IN highp vec4 aRectPosition; \n"
|
||||||
"IN lowp vec4 aRectColor; \n"
|
|
||||||
" \n"
|
" \n"
|
||||||
"OUT lowp vec4 vShadeColor; \n"
|
"OUT lowp vec4 vShadeColor; \n"
|
||||||
|
"uniform lowp vec4 uRectColor; \n"
|
||||||
"void main() \n"
|
"void main() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" gl_Position = aRectPosition; \n"
|
" gl_Position = aRectPosition; \n"
|
||||||
" vShadeColor = aRectColor; \n"
|
" vShadeColor = uRectColor; \n"
|
||||||
;
|
;
|
||||||
if (!_glinfo.isGLESX) {
|
if (!_glinfo.isGLESX) {
|
||||||
m_part +=
|
m_part +=
|
||||||
|
|
|
@ -638,6 +638,22 @@ private:
|
||||||
fUniform uK5;
|
fUniform uK5;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class URectColor : public UniformGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
URectColor(GLuint _program) {
|
||||||
|
LocateUniform(uRectColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(bool _force) override
|
||||||
|
{
|
||||||
|
uRectColor.set(&gDP.rectColor.r, _force);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
fv4Uniform uRectColor;
|
||||||
|
};
|
||||||
|
|
||||||
class UTextureSize : public UniformGroup
|
class UTextureSize : public UniformGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -772,8 +788,10 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
|
||||||
if (config.generalEmulation.enableNoise != 0)
|
if (config.generalEmulation.enableNoise != 0)
|
||||||
_uniforms.emplace_back(new UNoiseTex(_program));
|
_uniforms.emplace_back(new UNoiseTex(_program));
|
||||||
|
|
||||||
if (!m_glInfo.isGLES2)
|
if (!m_glInfo.isGLES2) {
|
||||||
_uniforms.emplace_back(new UDepthTex(_program));
|
_uniforms.emplace_back(new UDepthTex(_program));
|
||||||
|
_uniforms.emplace_back(new UDepthScale(_program));
|
||||||
|
}
|
||||||
|
|
||||||
if (_inputs.usesTexture()) {
|
if (_inputs.usesTexture()) {
|
||||||
_uniforms.emplace_back(new UTextures(_program));
|
_uniforms.emplace_back(new UTextures(_program));
|
||||||
|
@ -820,9 +838,6 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
|
||||||
|
|
||||||
_uniforms.emplace_back(new UAlphaTestInfo(_program));
|
_uniforms.emplace_back(new UAlphaTestInfo(_program));
|
||||||
|
|
||||||
if (!m_glInfo.isGLES2)
|
|
||||||
_uniforms.emplace_back(new UDepthScale(_program));
|
|
||||||
|
|
||||||
if (config.frameBufferEmulation.N64DepthCompare != 0)
|
if (config.frameBufferEmulation.N64DepthCompare != 0)
|
||||||
_uniforms.emplace_back(new UDepthInfo(_program));
|
_uniforms.emplace_back(new UDepthInfo(_program));
|
||||||
|
|
||||||
|
@ -834,6 +849,9 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
|
||||||
|
|
||||||
_uniforms.emplace_back(new UColors(_program));
|
_uniforms.emplace_back(new UColors(_program));
|
||||||
|
|
||||||
|
if (_key.isRectKey())
|
||||||
|
_uniforms.emplace_back(new URectColor(_program));
|
||||||
|
|
||||||
if (_inputs.usesHwLighting())
|
if (_inputs.usesHwLighting())
|
||||||
_uniforms.emplace_back(new ULights(_program));
|
_uniforms.emplace_back(new ULights(_program));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ void Utils::locateAttributes(GLuint _program, bool _rect, bool _textures)
|
||||||
{
|
{
|
||||||
if (_rect) {
|
if (_rect) {
|
||||||
glBindAttribLocation(_program, opengl::rectAttrib::position, "aRectPosition");
|
glBindAttribLocation(_program, opengl::rectAttrib::position, "aRectPosition");
|
||||||
glBindAttribLocation(_program, opengl::rectAttrib::color, "aRectColor");
|
|
||||||
if (_textures) {
|
if (_textures) {
|
||||||
glBindAttribLocation(_program, opengl::rectAttrib::texcoord0, "aTexCoord0");
|
glBindAttribLocation(_program, opengl::rectAttrib::texcoord0, "aTexCoord0");
|
||||||
glBindAttribLocation(_program, opengl::rectAttrib::texcoord1, "aTexCoord1");
|
glBindAttribLocation(_program, opengl::rectAttrib::texcoord1, "aTexCoord1");
|
||||||
|
|
|
@ -3,18 +3,17 @@
|
||||||
namespace opengl {
|
namespace opengl {
|
||||||
|
|
||||||
namespace triangleAttrib {
|
namespace triangleAttrib {
|
||||||
const GLuint position = 1U;
|
const GLuint position = 0U;
|
||||||
const GLuint color = 2U;
|
const GLuint color = 1U;
|
||||||
const GLuint texcoord = 3U;
|
const GLuint texcoord = 2U;
|
||||||
const GLuint numlights = 4U;
|
const GLuint numlights = 3U;
|
||||||
const GLuint modify = 5U;
|
const GLuint modify = 4U;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rect attributes
|
// Rect attributes
|
||||||
namespace rectAttrib {
|
namespace rectAttrib {
|
||||||
const GLuint position = 6U;
|
const GLuint position = 5U;
|
||||||
const GLuint color = 7U;
|
const GLuint texcoord0 = 6U;
|
||||||
const GLuint texcoord0 = 8U;
|
const GLuint texcoord1 = 7U;
|
||||||
const GLuint texcoord1 = 9U;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace opengl {
|
||||||
// Rect attributes
|
// Rect attributes
|
||||||
namespace rectAttrib {
|
namespace rectAttrib {
|
||||||
extern const GLuint position;
|
extern const GLuint position;
|
||||||
extern const GLuint color;
|
|
||||||
extern const GLuint texcoord0;
|
extern const GLuint texcoord0;
|
||||||
extern const GLuint texcoord1;
|
extern const GLuint texcoord1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ BufferedDrawer::BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray *
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, true);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, true);
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true);
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, true);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, true);
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, false);
|
|
||||||
glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, x)));
|
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::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::texcoord1, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, s1)));
|
||||||
|
@ -134,8 +133,6 @@ void BufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _pa
|
||||||
{
|
{
|
||||||
_updateRectBuffer(_params);
|
_updateRectBuffer(_params);
|
||||||
|
|
||||||
glVertexAttrib4fv(rectAttrib::color, _params.rectColor.data());
|
|
||||||
|
|
||||||
glDrawArrays(GLenum(_params.mode), m_rectsBuffers.vbo.pos - _params.verticesCount, _params.verticesCount);
|
glDrawArrays(GLenum(_params.mode), m_rectsBuffers.vbo.pos - _params.verticesCount, _params.verticesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ UnbufferedDrawer::UnbufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArr
|
||||||
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
|
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
|
||||||
|
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, false);
|
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
|
||||||
|
|
||||||
|
@ -97,8 +96,6 @@ void UnbufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _
|
||||||
glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), ptr);
|
glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
glVertexAttrib4fv(rectAttrib::color, _params.rectColor.data());
|
|
||||||
|
|
||||||
if (_params.combiner->usesTile(0)) {
|
if (_params.combiner->usesTile(0)) {
|
||||||
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true);
|
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true);
|
||||||
const void * ptr = &_params.vertices->s0;
|
const void * ptr = &_params.vertices->s0;
|
||||||
|
|
|
@ -835,6 +835,14 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pC
|
||||||
if (!_canDraw())
|
if (!_canDraw())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||||
|
gDP.rectColor.r = _pColor[0];
|
||||||
|
gDP.rectColor.g = _pColor[1];
|
||||||
|
gDP.rectColor.b = _pColor[2];
|
||||||
|
gDP.rectColor.a = _pColor[3];
|
||||||
|
} else {
|
||||||
|
gDP.rectColor = gDPInfo::Color();
|
||||||
|
}
|
||||||
gSP.changed &= ~CHANGED_GEOMETRYMODE; // Don't update cull mode
|
gSP.changed &= ~CHANGED_GEOMETRYMODE; // Don't update cull mode
|
||||||
if (gSP.changed || gDP.changed)
|
if (gSP.changed || gDP.changed)
|
||||||
_updateStates(DrawingState::Rect);
|
_updateStates(DrawingState::Rect);
|
||||||
|
@ -879,10 +887,6 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pC
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
if (gDP.otherMode.cycleType == G_CYC_FILL)
|
|
||||||
std::copy_n(_pColor, 4, rectParams.rectColor.begin());
|
|
||||||
else
|
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
rectParams.vertices = m_rect;
|
rectParams.vertices = m_rect;
|
||||||
rectParams.combiner = currentCombiner();
|
rectParams.combiner = currentCombiner();
|
||||||
|
@ -1052,7 +1056,6 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
{
|
{
|
||||||
gSP.changed &= ~CHANGED_GEOMETRYMODE; // Don't update cull mode
|
gSP.changed &= ~CHANGED_GEOMETRYMODE; // Don't update cull mode
|
||||||
m_drawingState = DrawingState::TexRect;
|
m_drawingState = DrawingState::TexRect;
|
||||||
f32 alpha = 0.0f;
|
|
||||||
|
|
||||||
if (!m_texrectDrawer.isEmpty()) {
|
if (!m_texrectDrawer.isEmpty()) {
|
||||||
CombinerInfo & cmbInfo = CombinerInfo::get();
|
CombinerInfo & cmbInfo = CombinerInfo::get();
|
||||||
|
@ -1061,19 +1064,16 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
_updateTextures();
|
_updateTextures();
|
||||||
cmbInfo.updateParameters();
|
cmbInfo.updateParameters();
|
||||||
} else {
|
} else {
|
||||||
|
gDP.rectColor = gDPInfo::Color();
|
||||||
|
if (gDP.otherMode.cycleType < G_CYC_COPY) {
|
||||||
|
if (gDP.combine.mA0 == G_ACMUX_0 && gDP.combine.aA0 == G_ACMUX_SHADE)
|
||||||
|
gDP.rectColor.a = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (_params.texrectCmd && (gSP.changed | gDP.changed) != 0)
|
if (_params.texrectCmd && (gSP.changed | gDP.changed) != 0)
|
||||||
_updateStates(DrawingState::TexRect);
|
_updateStates(DrawingState::TexRect);
|
||||||
gfxContext.enable(enable::CULL_FACE, false);
|
gfxContext.enable(enable::CULL_FACE, false);
|
||||||
|
|
||||||
if (CombinerInfo::get().isChanged()) {
|
|
||||||
if (currentCombiner()->usesShade()) {
|
|
||||||
gDPCombine combine;
|
|
||||||
combine.mux = currentCombiner()->getKey().getMux();
|
|
||||||
if (combine.mA0 == G_ACMUX_0 && combine.aA0 == G_ACMUX_SHADE)
|
|
||||||
alpha = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_params.texrectCmd && texturedRectSpecial != nullptr && texturedRectSpecial(_params)) {
|
if (_params.texrectCmd && texturedRectSpecial != nullptr && texturedRectSpecial(_params)) {
|
||||||
gSP.changed |= CHANGED_GEOMETRYMODE;
|
gSP.changed |= CHANGED_GEOMETRYMODE;
|
||||||
return;
|
return;
|
||||||
|
@ -1253,8 +1253,6 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.rectColor[3] = alpha;
|
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
rectParams.vertices = m_rect;
|
rectParams.vertices = m_rect;
|
||||||
rectParams.combiner = currentCombiner();
|
rectParams.combiner = currentCombiner();
|
||||||
|
@ -1466,7 +1464,6 @@ void GraphicsDrawer::copyTexturedRect(const CopyRectParams & _params)
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
rectParams.vertices = m_rect;
|
rectParams.vertices = m_rect;
|
||||||
rectParams.combiner = _params.combiner;
|
rectParams.combiner = _params.combiner;
|
||||||
|
|
|
@ -173,7 +173,6 @@ void TexrectDrawer::add()
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
rectParams.vertices = pRect;
|
rectParams.vertices = pRect;
|
||||||
rectParams.combiner = currentCombiner();
|
rectParams.combiner = currentCombiner();
|
||||||
|
@ -286,7 +285,6 @@ bool TexrectDrawer::draw()
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
rectParams.vertices = rect;
|
rectParams.vertices = rect;
|
||||||
rectParams.combiner = m_programTex.get();
|
rectParams.combiner = m_programTex.get();
|
||||||
|
|
|
@ -344,7 +344,6 @@ void TextDrawer::drawText(const char *_pText, float _x, float _y) const
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLES;
|
rectParams.mode = drawmode::TRIANGLES;
|
||||||
rectParams.rectColor.fill(0.0f);
|
|
||||||
rectParams.verticesCount = coords.size();
|
rectParams.verticesCount = coords.size();
|
||||||
rectParams.vertices = coords.data();
|
rectParams.vertices = coords.data();
|
||||||
rectParams.combiner = m_program.get();
|
rectParams.combiner = m_program.get();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user