renderer_opengl: Address buffer overflow
This commit is contained in:
@ -122,10 +122,8 @@ public:
|
||||
QSurfaceFormat format;
|
||||
|
||||
if (Settings::values.graphics_api == Settings::GraphicsAPI::OpenGLES) {
|
||||
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||
format.setVersion(3, 2);
|
||||
} else {
|
||||
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
format.setVersion(4, 4);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
}
|
||||
|
@ -1240,7 +1240,7 @@ ShaderDecompiler::ProgramResult GenerateFragmentShader(const PicaFSConfig& confi
|
||||
in vec4 gl_FragCoord;
|
||||
#endif // CITRA_GLES
|
||||
|
||||
out vec4 color;
|
||||
layout (location = 0) out vec4 color;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
@ -453,6 +453,7 @@ void ShaderProgramManager::ApplyTo(OpenGLState& state) {
|
||||
glUseProgramStages(impl->pipeline.handle, GL_VERTEX_SHADER_BIT, impl->current.vs);
|
||||
glUseProgramStages(impl->pipeline.handle, GL_GEOMETRY_SHADER_BIT, impl->current.gs);
|
||||
glUseProgramStages(impl->pipeline.handle, GL_FRAGMENT_SHADER_BIT, impl->current.fs);
|
||||
|
||||
state.draw.shader_program = 0;
|
||||
state.draw.program_pipeline = impl->pipeline.handle;
|
||||
} else {
|
||||
|
@ -68,6 +68,7 @@ const StagingBuffer& TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||
// Attempt to find a free buffer that fits the requested data
|
||||
for (auto it = search.lower_bound({.size = size}); it != search.end(); it++) {
|
||||
if (!upload || it->IsFree()) {
|
||||
it->mapped = std::span{it->mapped.data(), size};
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@ -132,6 +133,7 @@ void TextureRuntime::FormatConvert(const Surface& surface, bool upload,
|
||||
} else if (format == VideoCore::PixelFormat::RGB8 && driver.IsOpenGLES()) {
|
||||
Pica::Texture::ConvertBGRToRGB(source, dest);
|
||||
} else {
|
||||
ASSERT(dest.size() >= source.size());
|
||||
std::memcpy(dest.data(), source.data(), source.size());
|
||||
}
|
||||
}
|
||||
@ -311,10 +313,13 @@ void TextureRuntime::BindFramebuffer(GLenum target, GLint level, GLenum textarge
|
||||
|
||||
Surface::Surface(VideoCore::SurfaceParams& params, TextureRuntime& runtime)
|
||||
: VideoCore::SurfaceBase<Surface>{params}, runtime{runtime}, driver{runtime.GetDriver()} {
|
||||
if (pixel_format != VideoCore::PixelFormat::Invalid) {
|
||||
texture = runtime.Allocate(GetScaledWidth(), GetScaledHeight(), params.pixel_format, texture_type);
|
||||
}
|
||||
}
|
||||
|
||||
Surface::~Surface() {
|
||||
if (pixel_format != VideoCore::PixelFormat::Invalid) {
|
||||
const VideoCore::HostTextureTag tag = {
|
||||
.format = pixel_format,
|
||||
.width = GetScaledWidth(),
|
||||
@ -324,6 +329,7 @@ Surface::~Surface() {
|
||||
|
||||
runtime.texture_recycler.emplace(tag, std::move(texture));
|
||||
}
|
||||
}
|
||||
|
||||
MICROPROFILE_DEFINE(OpenGL_Upload, "OpenGLSurface", "Texture Upload", MP_RGB(128, 192, 64));
|
||||
void Surface::Upload(const VideoCore::BufferTextureCopy& upload, const StagingBuffer& staging) {
|
||||
|
@ -22,7 +22,7 @@ struct FormatTuple {
|
||||
struct StagingBuffer {
|
||||
OGLBuffer buffer{};
|
||||
mutable OGLSync buffer_lock{};
|
||||
std::span<std::byte> mapped{};
|
||||
mutable std::span<std::byte> mapped{};
|
||||
u32 size{};
|
||||
|
||||
bool operator<(const StagingBuffer& other) const {
|
||||
|
Reference in New Issue
Block a user