Skip to content

Commit

Permalink
[PR 114] Revert OpenGL shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Jul 18, 2022
1 parent 3b6aeb3 commit 5500c3a
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 1,484 deletions.
1 change: 0 additions & 1 deletion cmake/treedata/linux/subdirs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
xbmc/cores/RetroPlayer/shaders/gl cores/RetroPlayer/shaders/gl
xbmc/input/touch input/touch
xbmc/input/touch/generic input/touch/generic
xbmc/platform/common/speech platform/common/speech
Expand Down
1 change: 0 additions & 1 deletion cmake/treedata/osx/subdirs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
xbmc/cores/RetroPlayer/process/osx cores/RetroPlayer/process/osx
xbmc/cores/RetroPlayer/shaders/gl cores/RetroPlayer/shaders/gl
xbmc/cores/VideoPlayer/Process/osx cores/VideoPlayer/Process/osx
xbmc/platform/darwin platform/darwin
xbmc/platform/darwin/network platform/darwin/network
Expand Down
117 changes: 35 additions & 82 deletions xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPRendererOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "cores/RetroPlayer/buffers/RenderBufferOpenGL.h"
#include "cores/RetroPlayer/buffers/RenderBufferPoolOpenGL.h"
#include "cores/RetroPlayer/rendering/RenderContext.h"
#include "cores/RetroPlayer/shaders/gl/ShaderPresetGL.h"
#include "utils/GLUtils.h"
#include "utils/log.h"

Expand Down Expand Up @@ -47,9 +46,6 @@ CRPRendererOpenGL::CRPRendererOpenGL(const CRenderSettings& renderSettings,
std::shared_ptr<IRenderBufferPool> bufferPool)
: CRPBaseRenderer(renderSettings, context, std::move(bufferPool))
{
// Initialize CRPBaseRenderer
m_shaderPreset.reset(new SHADER::CShaderPresetGL(m_context));

// Initialize CRPRendererOpenGL
m_clearColour = m_context.UseLimitedColor() ? (16.0f / 0xff) : 0.0f;

Expand Down Expand Up @@ -282,103 +278,60 @@ void CRPRendererOpenGL::Render(uint8_t alpha)

const uint32_t color = (alpha << 24) | 0xFFFFFF;

RenderBufferTextures* rbTextures;
const auto it = m_RBTexturesMap.find(renderBuffer);
if (it != m_RBTexturesMap.end())
{
rbTextures = it->second.get();
}
else
{
// We can't copy or move CGLTexture, so construct source/target in-place
rbTextures = new RenderBufferTextures{{// source texture
static_cast<unsigned int>(renderBuffer->GetWidth()),
static_cast<unsigned int>(renderBuffer->GetHeight()),
GL_RGB, renderBuffer->TextureID()},
{// target texture
static_cast<unsigned int>(m_context.GetScreenWidth()),
static_cast<unsigned int>(m_context.GetScreenHeight())}};
m_RBTexturesMap.emplace(renderBuffer, rbTextures);
}

const auto sourceTexture = &rbTextures->source;
const auto targetTexture = &rbTextures->target;

glBindTexture(m_textureTarget, sourceTexture->getMTexture());
glBindTexture(m_textureTarget, renderBuffer->TextureID());

GLint filter = GL_NEAREST;
if (GetRenderSettings().VideoSettings().GetScalingMethod() == SCALINGMETHOD::LINEAR)
filter = GL_LINEAR;

glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Updateshaders();

if (m_bUseShaderPreset)
{
const CPoint destPoints[4] = {m_rotatedDestCoords[0], m_rotatedDestCoords[1],
m_rotatedDestCoords[2], m_rotatedDestCoords[3]};

targetTexture->CreateTextureObject();

SHADER::CShaderTextureGL source(*sourceTexture);
SHADER::CShaderTextureGL target(*targetTexture);
if (!m_shaderPreset->RenderUpdate(destPoints, &source, &target))
{
m_shadersNeedUpdate = false;
m_bUseShaderPreset = false;
}
}
else
{
m_context.EnableGUIShader(GL_SHADER_METHOD::TEXTURE);
m_context.EnableGUIShader(GL_SHADER_METHOD::TEXTURE);

GLubyte colour[4];
GLubyte idx[4] = {0, 1, 3, 2}; // Determines order of triangle strip
PackedVertex vertex[4];
GLubyte colour[4];
GLubyte idx[4] = {0, 1, 3, 2}; // Determines order of triangle strip
PackedVertex vertex[4];

GLint uniColLoc = m_context.GUIShaderGetUniCol();
GLint uniColLoc = m_context.GUIShaderGetUniCol();

// Setup color values
colour[0] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::R, color);
colour[1] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::G, color);
colour[2] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::B, color);
colour[3] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::A, color);
// Setup color values
colour[0] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::R, color);
colour[1] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::G, color);
colour[2] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::B, color);
colour[3] = UTILS::GL::GetChannelFromARGB(UTILS::GL::ColorChannel::A, color);

for (unsigned int i = 0; i < 4; i++)
{
// Setup vertex position values
vertex[i].x = m_rotatedDestCoords[i].x;
vertex[i].y = m_rotatedDestCoords[i].y;
vertex[i].z = 0.0f;
}
for (unsigned int i = 0; i < 4; i++)
{
// Setup vertex position values
vertex[i].x = m_rotatedDestCoords[i].x;
vertex[i].y = m_rotatedDestCoords[i].y;
vertex[i].z = 0.0f;
}

// Setup texture coordinates
vertex[0].u1 = vertex[3].u1 = rect.x1;
vertex[0].v1 = vertex[1].v1 = rect.y1;
vertex[1].u1 = vertex[2].u1 = rect.x2;
vertex[2].v1 = vertex[3].v1 = rect.y2;
// Setup texture coordinates
vertex[0].u1 = vertex[3].u1 = rect.x1;
vertex[0].v1 = vertex[1].v1 = rect.y1;
vertex[1].u1 = vertex[2].u1 = rect.x2;
vertex[2].v1 = vertex[3].v1 = rect.y2;

glBindVertexArray(m_mainVAO);
glBindVertexArray(m_mainVAO);

glBindBuffer(GL_ARRAY_BUFFER, m_mainVertexVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(PackedVertex) * 4, &vertex[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, m_mainVertexVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(PackedVertex) * 4, &vertex[0], GL_STATIC_DRAW);

// No need to bind the index VBO, it's part of VAO state
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte) * 4, idx, GL_STATIC_DRAW);
// No need to bind the index VBO, it's part of VAO state
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte) * 4, idx, GL_STATIC_DRAW);

glUniform4f(uniColLoc, (colour[0] / 255.0f), (colour[1] / 255.0f), (colour[2] / 255.0f),
(colour[3] / 255.0f));
glUniform4f(uniColLoc, (colour[0] / 255.0f), (colour[1] / 255.0f), (colour[2] / 255.0f),
(colour[3] / 255.0f));

glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, 0);
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, 0);

// Unbind VAO/VBO just to be safe
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Unbind VAO/VBO just to be safe
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

m_context.DisableGUIShader();
}
m_context.DisableGUIShader();
}
12 changes: 0 additions & 12 deletions xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPRendererOpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include "RPBaseRenderer.h"
#include "cores/RetroPlayer/process/RPProcessInfo.h"
#include "guilib/TextureGL.h"

#include <map>
#include <memory>

#include "system_gl.h"

Expand All @@ -22,7 +18,6 @@ namespace KODI
namespace RETRO
{
class CRenderContext;
class CRenderBufferOpenGL;

class CRendererFactoryOpenGL : public IRendererFactory
{
Expand Down Expand Up @@ -63,11 +58,6 @@ class CRPRendererOpenGL : public CRPBaseRenderer
float y;
float z;
};
struct RenderBufferTextures
{
CGLTexture source;
CGLTexture target;
};

// implementation of CRPBaseRenderer
void RenderInternal(bool clear, uint8_t alpha) override;
Expand All @@ -88,8 +78,6 @@ class CRPRendererOpenGL : public CRPBaseRenderer

virtual void Render(uint8_t alpha);

std::map<CRenderBufferOpenGL*, std::unique_ptr<RenderBufferTextures>> m_RBTexturesMap;

GLuint m_mainVAO;
GLuint m_mainVertexVBO;
GLuint m_mainIndexVBO;
Expand Down
16 changes: 0 additions & 16 deletions xbmc/cores/RetroPlayer/shaders/gl/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 5500c3a

Please sign in to comment.