mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #10603 from unknownbrackets/gl-render-manager
Fix OpenGL on Windows XP
This commit is contained in:
commit
c6a9c884bf
13 changed files with 43 additions and 32 deletions
|
@ -283,9 +283,9 @@ bool VulkanDeviceAllocator::AllocateFromSlab(Slab &slab, size_t &start, size_t b
|
|||
int VulkanDeviceAllocator::ComputeUsagePercent() const {
|
||||
int blockSum = 0;
|
||||
int blocksUsed = 0;
|
||||
for (int i = 0; i < slabs_.size(); i++) {
|
||||
for (size_t i = 0; i < slabs_.size(); i++) {
|
||||
blockSum += (int)slabs_[i].usage.size();
|
||||
for (int j = 0; j < slabs_[i].usage.size(); j++) {
|
||||
for (size_t j = 0; j < slabs_[i].usage.size(); j++) {
|
||||
blocksUsed += slabs_[i].usage[j] != 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ std::vector<std::string> CWCheatEngine::GetCodesList() {
|
|||
// It also goes through other "_" lines, but they all have to meet this requirement anyway
|
||||
// so we don't have to specify any syntax checks here that are made by cheat engine.
|
||||
if (line.length() >= 5 && line[0] == '_') {
|
||||
for (int i = 4; i < line.length(); i++) {
|
||||
for (size_t i = 4; i < line.length(); i++) {
|
||||
if (line[i] != ' ') {
|
||||
validCheatLine = true;
|
||||
break;
|
||||
|
|
|
@ -29,7 +29,7 @@ const char *ElfReader::GetSectionName(int section) const {
|
|||
return nullptr;
|
||||
|
||||
int nameOffset = sections[section].sh_name;
|
||||
if (nameOffset < 0 || nameOffset >= size_) {
|
||||
if (nameOffset < 0 || (size_t)nameOffset >= size_) {
|
||||
ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2017- PPSSPP Project.
|
||||
// Copyright (c) 2017- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -50,9 +50,9 @@ void BlobFileSystem::CloseFile(u32 handle) {
|
|||
size_t BlobFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
|
||||
auto entry = entries_.find(handle);
|
||||
if (entry != entries_.end()) {
|
||||
size_t readSize = fileLoader_->ReadAt(entry->second, size, pointer);
|
||||
s64 readSize = fileLoader_->ReadAt(entry->second, size, pointer);
|
||||
entry->second += readSize;
|
||||
return readSize;
|
||||
return (size_t)readSize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ GLRTexture *DepalShaderCacheGLES::GetClutTexture(GEPaletteFormat clutFormat, con
|
|||
|
||||
uint8_t *clutCopy = new uint8_t[1024];
|
||||
memcpy(clutCopy, rawClut, 1024);
|
||||
render_->TextureImage(tex->texture, 0, texturePixels, 1, components, components2, dstFmt, clutCopy, false);
|
||||
render_->TextureImage(tex->texture, 0, texturePixels, 1, components, components2, dstFmt, clutCopy, GLRAllocType::NEW, false);
|
||||
|
||||
tex->lastFrame = gpuStats.numFlips;
|
||||
texCache_[clutId] = tex;
|
||||
|
|
|
@ -777,7 +777,7 @@ void DrawEngineGLES::TessellationDataTransferGLES::SendDataToShader(const float
|
|||
uint8_t *pos_data = new uint8_t[size * sizeof(float) * 4];
|
||||
memcpy(pos_data, pos, size * sizeof(float) * 4);
|
||||
data_tex[0] = renderManager_->CreateTexture(GL_TEXTURE_2D);
|
||||
renderManager_->TextureImage(data_tex[0], 0, size, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, pos_data, false);
|
||||
renderManager_->TextureImage(data_tex[0], 0, size, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, pos_data, GLRAllocType::NEW, false);
|
||||
renderManager_->FinalizeTexture(data_tex[0], 0, false);
|
||||
renderManager_->BindTexture(4, data_tex[0]);
|
||||
|
||||
|
@ -788,7 +788,7 @@ void DrawEngineGLES::TessellationDataTransferGLES::SendDataToShader(const float
|
|||
uint8_t *tex_data = new uint8_t[size * sizeof(float) * 4];
|
||||
memcpy(tex_data, pos, size * sizeof(float) * 4);
|
||||
data_tex[1] = renderManager_->CreateTexture(GL_TEXTURE_2D);
|
||||
renderManager_->TextureImage(data_tex[1], 0, size, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, tex_data, false);
|
||||
renderManager_->TextureImage(data_tex[1], 0, size, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, tex_data, GLRAllocType::NEW, false);
|
||||
renderManager_->FinalizeTexture(data_tex[1], 0, false);
|
||||
renderManager_->BindTexture(5, data_tex[1]);
|
||||
}
|
||||
|
@ -800,7 +800,7 @@ void DrawEngineGLES::TessellationDataTransferGLES::SendDataToShader(const float
|
|||
uint8_t *col_data = new uint8_t[sizeColor * sizeof(float) * 4];
|
||||
memcpy(col_data, col, sizeColor * sizeof(float) * 4);
|
||||
|
||||
renderManager_->TextureImage(data_tex[2], 0, sizeColor, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, col_data, false);
|
||||
renderManager_->TextureImage(data_tex[2], 0, sizeColor, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, col_data, GLRAllocType::NEW, false);
|
||||
renderManager_->FinalizeTexture(data_tex[2], 0, false);
|
||||
renderManager_->BindTexture(6, data_tex[2]);
|
||||
}
|
||||
|
|
|
@ -367,7 +367,7 @@ void FramebufferManagerGLES::MakePixelTexture(const u8 *srcPixels, GEBufferForma
|
|||
break;
|
||||
}
|
||||
}
|
||||
render_->TextureImage(drawPixelsTex_, 0, texWidth, height, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, convBuf, false);
|
||||
render_->TextureImage(drawPixelsTex_, 0, texWidth, height, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, convBuf, GLRAllocType::NEW, false);
|
||||
render_->FinalizeTexture(drawPixelsTex_, 0, false);
|
||||
|
||||
// TODO: Return instead?
|
||||
|
|
|
@ -714,7 +714,7 @@ u8 *TextureCacheGLES::DecodeTextureLevelOld(GETextureFormat format, GEPaletteFor
|
|||
decPitch = bufw * pixelSize;
|
||||
}
|
||||
|
||||
uint8_t *texBuf = new uint8_t[std::max(w, bufw) * h * pixelSize];
|
||||
uint8_t *texBuf = (uint8_t *)AllocateAlignedMemory(std::max(w, bufw) * h * pixelSize, 16);
|
||||
DecodeTextureLevel(texBuf, decPitch, format, clutformat, texaddr, level, bufw, true, false, false);
|
||||
return texBuf;
|
||||
}
|
||||
|
@ -755,7 +755,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
|||
PROFILE_THIS_SCOPE("replacetex");
|
||||
|
||||
int bpp = replaced.Format(level) == ReplacedTextureFormat::F_8888 ? 4 : 2;
|
||||
uint8_t *rearrange = new uint8_t[w * h * bpp];
|
||||
uint8_t *rearrange = (uint8_t *)AllocateAlignedMemory(w * h * bpp, 16);
|
||||
replaced.Load(level, rearrange, bpp * w);
|
||||
pixelData = rearrange;
|
||||
|
||||
|
@ -785,7 +785,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
|||
}
|
||||
|
||||
if (scaleFactor > 1) {
|
||||
uint8_t *rearrange = new uint8_t[w * scaleFactor * h * scaleFactor * 4];
|
||||
uint8_t *rearrange = (uint8_t *)AllocateAlignedMemory(w * scaleFactor * h * scaleFactor * 4, 16);
|
||||
scaler.ScaleAlways((u32 *)rearrange, (u32 *)pixelData, dstFmt, w, h, scaleFactor);
|
||||
pixelData = rearrange;
|
||||
delete [] finalBuf;
|
||||
|
@ -817,9 +817,9 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
|||
} else {
|
||||
PROFILE_THIS_SCOPE("loadtex");
|
||||
if (IsFakeMipmapChange())
|
||||
render_->TextureImage(entry.textureName, 0, w, h, components, components2, dstFmt, pixelData);
|
||||
render_->TextureImage(entry.textureName, 0, w, h, components, components2, dstFmt, pixelData, GLRAllocType::ALIGNED);
|
||||
else
|
||||
render_->TextureImage(entry.textureName, level, w, h, components, components2, dstFmt, pixelData);
|
||||
render_->TextureImage(entry.textureName, level, w, h, components, components2, dstFmt, pixelData, GLRAllocType::ALIGNED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void DrawAllocatorVis(UIContext *ui, GPUInterface *gpu) {
|
|||
uint32_t *wideData = (uint32_t *)initData.data();
|
||||
|
||||
// Convert to nice colors. If we really wanted to save on memory, we could use a 16-bit texture...
|
||||
for (int j = 0; j < usage.size(); j++) {
|
||||
for (size_t j = 0; j < usage.size(); j++) {
|
||||
switch (usage[j]) {
|
||||
case 0: wideData[j] = 0xFF333333; break;
|
||||
case 1: wideData[j] = 0xFF33FF33; break;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "Common/MemoryUtil.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "GLQueueRunner.h"
|
||||
#include "GLRenderManager.h"
|
||||
|
@ -65,7 +66,7 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
|
|||
GLuint boundTexture = (GLuint)-1;
|
||||
bool allocatedTextures = false;
|
||||
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
for (size_t i = 0; i < steps.size(); i++) {
|
||||
const GLRInitStep &step = steps[i];
|
||||
switch (step.stepType) {
|
||||
case GLRInitStepType::CREATE_TEXTURE:
|
||||
|
@ -98,9 +99,9 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
|
|||
GLRProgram *program = step.create_program.program;
|
||||
program->program = glCreateProgram();
|
||||
_assert_msg_(G3D, step.create_program.num_shaders > 0, "Can't create a program with zero shaders");
|
||||
for (int i = 0; i < step.create_program.num_shaders; i++) {
|
||||
_dbg_assert_msg_(G3D, step.create_program.shaders[i]->shader, "Can't create a program with a null shader");
|
||||
glAttachShader(program->program, step.create_program.shaders[i]->shader);
|
||||
for (int j = 0; j < step.create_program.num_shaders; j++) {
|
||||
_dbg_assert_msg_(G3D, step.create_program.shaders[j]->shader, "Can't create a program with a null shader");
|
||||
glAttachShader(program->program, step.create_program.shaders[j]->shader);
|
||||
}
|
||||
|
||||
for (auto iter : program->semantics_) {
|
||||
|
@ -161,15 +162,15 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
|
|||
glUseProgram(program->program);
|
||||
|
||||
// Query all the uniforms.
|
||||
for (int i = 0; i < program->queries_.size(); i++) {
|
||||
auto &x = program->queries_[i];
|
||||
for (size_t j = 0; j < program->queries_.size(); j++) {
|
||||
auto &x = program->queries_[j];
|
||||
assert(x.name);
|
||||
*x.dest = glGetUniformLocation(program->program, x.name);
|
||||
}
|
||||
|
||||
// Run initializers.
|
||||
for (int i = 0; i < program->initialize_.size(); i++) {
|
||||
auto &init = program->initialize_[i];
|
||||
for (size_t j = 0; j < program->initialize_.size(); j++) {
|
||||
auto &init = program->initialize_[j];
|
||||
GLint uniform = *init.uniform;
|
||||
if (uniform != -1) {
|
||||
switch (init.type) {
|
||||
|
@ -241,7 +242,11 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
|
|||
// For things to show in RenderDoc, need to split into glTexImage2D(..., nullptr) and glTexSubImage.
|
||||
glTexImage2D(tex->target, step.texture_image.level, step.texture_image.internalFormat, step.texture_image.width, step.texture_image.height, 0, step.texture_image.format, step.texture_image.type, step.texture_image.data);
|
||||
allocatedTextures = true;
|
||||
delete[] step.texture_image.data;
|
||||
if (step.texture_image.allocType == GLRAllocType::ALIGNED) {
|
||||
FreeAlignedMemory(step.texture_image.data);
|
||||
} else {
|
||||
delete[] step.texture_image.data;
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
tex->wrapS = GL_CLAMP_TO_EDGE;
|
||||
tex->wrapT = GL_CLAMP_TO_EDGE;
|
||||
|
@ -399,7 +404,7 @@ void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) {
|
|||
}
|
||||
|
||||
void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps) {
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
for (size_t i = 0; i < steps.size(); i++) {
|
||||
const GLRStep &step = *steps[i];
|
||||
switch (step.stepType) {
|
||||
case GLRStepType::RENDER:
|
||||
|
|
|
@ -19,6 +19,10 @@ struct GLOffset2D {
|
|||
int x, y;
|
||||
};
|
||||
|
||||
enum class GLRAllocType {
|
||||
NEW,
|
||||
ALIGNED,
|
||||
};
|
||||
|
||||
class GLRShader;
|
||||
class GLRTexture;
|
||||
|
@ -242,6 +246,7 @@ struct GLRInitStep {
|
|||
int level;
|
||||
int width;
|
||||
int height;
|
||||
GLRAllocType allocType;
|
||||
bool linearFilter;
|
||||
uint8_t *data; // owned, delete[]-d
|
||||
} texture_image;
|
||||
|
|
|
@ -267,7 +267,7 @@ public:
|
|||
step.create_program.program->initialize_ = initalizers;
|
||||
step.create_program.support_dual_source = supportDualSource;
|
||||
_assert_msg_(G3D, shaders.size() > 0, "Can't create a program with zero shaders");
|
||||
for (int i = 0; i < shaders.size(); i++) {
|
||||
for (size_t i = 0; i < shaders.size(); i++) {
|
||||
step.create_program.shaders[i] = shaders[i];
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
|
@ -337,7 +337,7 @@ public:
|
|||
}
|
||||
|
||||
// Takes ownership over the data pointer and delete[]-s it.
|
||||
void TextureImage(GLRTexture *texture, int level, int width, int height, GLenum internalFormat, GLenum format, GLenum type, uint8_t *data, bool linearFilter = false) {
|
||||
void TextureImage(GLRTexture *texture, int level, int width, int height, GLenum internalFormat, GLenum format, GLenum type, uint8_t *data, GLRAllocType allocType = GLRAllocType::NEW, bool linearFilter = false) {
|
||||
GLRInitStep step{ GLRInitStepType::TEXTURE_IMAGE };
|
||||
step.texture_image.texture = texture;
|
||||
step.texture_image.data = data;
|
||||
|
@ -347,6 +347,7 @@ public:
|
|||
step.texture_image.level = level;
|
||||
step.texture_image.width = width;
|
||||
step.texture_image.height = height;
|
||||
step.texture_image.allocType = allocType;
|
||||
step.texture_image.linearFilter = linearFilter;
|
||||
initSteps_.push_back(step);
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ void VulkanQueueRunner::RunSteps(VkCommandBuffer cmd, const std::vector<VKRStep
|
|||
// * Create copies of render target that are rendered to multiple times and textured from in sequence, and push those render passes
|
||||
// as early as possible in the frame (Wipeout billboards).
|
||||
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
for (size_t i = 0; i < steps.size(); i++) {
|
||||
const VKRStep &step = *steps[i];
|
||||
switch (step.stepType) {
|
||||
case VKRStepType::RENDER:
|
||||
|
@ -266,7 +266,7 @@ void VulkanQueueRunner::RunSteps(VkCommandBuffer cmd, const std::vector<VKRStep
|
|||
|
||||
void VulkanQueueRunner::LogSteps(const std::vector<VKRStep *> &steps) {
|
||||
ILOG("=======================================");
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
for (size_t i = 0; i < steps.size(); i++) {
|
||||
const VKRStep &step = *steps[i];
|
||||
switch (step.stepType) {
|
||||
case VKRStepType::RENDER:
|
||||
|
|
Loading…
Add table
Reference in a new issue