mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
thin3d: Add support for texture subimage to GLRender.
This commit is contained in:
parent
0cb63318bc
commit
3add123587
3 changed files with 51 additions and 2 deletions
|
@ -306,14 +306,14 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
|||
glBindTexture(tex->target, tex->texture);
|
||||
boundTexture = tex->texture;
|
||||
}
|
||||
if (!step.texture_image.data)
|
||||
if (!step.texture_image.data && step.texture_image.allocType != GLRAllocType::NONE)
|
||||
Crash();
|
||||
// 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;
|
||||
if (step.texture_image.allocType == GLRAllocType::ALIGNED) {
|
||||
FreeAlignedMemory(step.texture_image.data);
|
||||
} else {
|
||||
} else if (step.texture_image.allocType == GLRAllocType::NEW) {
|
||||
delete[] step.texture_image.data;
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
|
@ -328,6 +328,26 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
|||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
}
|
||||
case GLRInitStepType::TEXTURE_SUBIMAGE:
|
||||
{
|
||||
GLRTexture *tex = step.texture_subimage.texture;
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
if (boundTexture != tex->texture) {
|
||||
glBindTexture(tex->target, tex->texture);
|
||||
boundTexture = tex->texture;
|
||||
}
|
||||
if (!step.texture_subimage.data)
|
||||
Crash();
|
||||
// For things to show in RenderDoc, need to split into glTexImage2D(..., nullptr) and glTexSubImage.
|
||||
glTexSubImage2D(tex->target, step.texture_subimage.level, step.texture_subimage.x, step.texture_subimage.y, step.texture_subimage.width, step.texture_subimage.height, step.texture_subimage.format, step.texture_subimage.type, step.texture_subimage.data);
|
||||
if (step.texture_subimage.allocType == GLRAllocType::ALIGNED) {
|
||||
FreeAlignedMemory(step.texture_subimage.data);
|
||||
} else if (step.texture_subimage.allocType == GLRAllocType::NEW) {
|
||||
delete[] step.texture_subimage.data;
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
}
|
||||
case GLRInitStepType::TEXTURE_FINALIZE:
|
||||
{
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
|
|
|
@ -20,6 +20,7 @@ struct GLOffset2D {
|
|||
};
|
||||
|
||||
enum class GLRAllocType {
|
||||
NONE,
|
||||
NEW,
|
||||
ALIGNED,
|
||||
};
|
||||
|
@ -196,6 +197,7 @@ enum class GLRInitStepType : uint8_t {
|
|||
CREATE_FRAMEBUFFER,
|
||||
|
||||
TEXTURE_IMAGE,
|
||||
TEXTURE_SUBIMAGE,
|
||||
TEXTURE_FINALIZE,
|
||||
BUFFER_SUBDATA,
|
||||
};
|
||||
|
@ -250,6 +252,18 @@ struct GLRInitStep {
|
|||
bool linearFilter;
|
||||
uint8_t *data; // owned, delete[]-d
|
||||
} texture_image;
|
||||
struct {
|
||||
GLRTexture *texture;
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
int level;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
GLRAllocType allocType;
|
||||
uint8_t *data; // owned, delete[]-d
|
||||
} texture_subimage;
|
||||
struct {
|
||||
GLRTexture *texture;
|
||||
int maxLevel;
|
||||
|
|
|
@ -530,6 +530,21 @@ public:
|
|||
initSteps_.push_back(step);
|
||||
}
|
||||
|
||||
void TextureSubImage(GLRTexture *texture, int level, int x, int y, int width, int height, GLenum format, GLenum type, uint8_t *data, GLRAllocType allocType = GLRAllocType::NEW) {
|
||||
GLRInitStep step{ GLRInitStepType::TEXTURE_SUBIMAGE };
|
||||
step.texture_subimage.texture = texture;
|
||||
step.texture_subimage.data = data;
|
||||
step.texture_subimage.format = format;
|
||||
step.texture_subimage.type = type;
|
||||
step.texture_subimage.level = level;
|
||||
step.texture_subimage.x = x;
|
||||
step.texture_subimage.y = y;
|
||||
step.texture_subimage.width = width;
|
||||
step.texture_subimage.height = height;
|
||||
step.texture_subimage.allocType = allocType;
|
||||
initSteps_.push_back(step);
|
||||
}
|
||||
|
||||
void FinalizeTexture(GLRTexture *texture, int maxLevels, bool genMips) {
|
||||
GLRInitStep step{ GLRInitStepType::TEXTURE_FINALIZE };
|
||||
step.texture_finalize.texture = texture;
|
||||
|
|
Loading…
Add table
Reference in a new issue