GL4: Track the internal format of render targets and match them based on that.

This commit is contained in:
Dr. Chat 2016-05-01 11:18:46 -05:00
parent ea7bad1035
commit 720f8b0dc2
2 changed files with 32 additions and 28 deletions

View File

@ -1968,20 +1968,6 @@ GLuint GL4CommandProcessor::GetColorRenderTarget(
format = ColorRenderTargetFormat::k_8_8_8_8; format = ColorRenderTargetFormat::k_8_8_8_8;
} }
for (auto it = cached_color_render_targets_.begin();
it != cached_color_render_targets_.end(); ++it) {
if (it->base == base && it->width == width && it->height == height &&
it->format == format) {
return it->texture;
}
}
cached_color_render_targets_.push_back(CachedColorRenderTarget());
auto cached = &cached_color_render_targets_.back();
cached->base = base;
cached->width = width;
cached->height = height;
cached->format = format;
GLenum internal_format; GLenum internal_format;
switch (format) { switch (format) {
case ColorRenderTargetFormat::k_8_8_8_8: case ColorRenderTargetFormat::k_8_8_8_8:
@ -2019,6 +2005,21 @@ GLuint GL4CommandProcessor::GetColorRenderTarget(
return 0; return 0;
} }
for (auto it = cached_color_render_targets_.begin();
it != cached_color_render_targets_.end(); ++it) {
if (it->base == base && it->width == width && it->height == height &&
it->internal_format == internal_format) {
return it->texture;
}
}
cached_color_render_targets_.push_back(CachedColorRenderTarget());
auto cached = &cached_color_render_targets_.back();
cached->base = base;
cached->width = width;
cached->height = height;
cached->format = format;
cached->internal_format = internal_format;
glCreateTextures(GL_TEXTURE_2D, 1, &cached->texture); glCreateTextures(GL_TEXTURE_2D, 1, &cached->texture);
glTextureStorage2D(cached->texture, 1, internal_format, width, height); glTextureStorage2D(cached->texture, 1, internal_format, width, height);
@ -2031,20 +2032,6 @@ GLuint GL4CommandProcessor::GetDepthRenderTarget(
uint32_t width = 2560; uint32_t width = 2560;
uint32_t height = 2560; uint32_t height = 2560;
for (auto it = cached_depth_render_targets_.begin();
it != cached_depth_render_targets_.end(); ++it) {
if (it->base == base && it->width == width && it->height == height &&
it->format == format) {
return it->texture;
}
}
cached_depth_render_targets_.push_back(CachedDepthRenderTarget());
auto cached = &cached_depth_render_targets_.back();
cached->base = base;
cached->width = width;
cached->height = height;
cached->format = format;
GLenum internal_format; GLenum internal_format;
switch (format) { switch (format) {
case DepthRenderTargetFormat::kD24S8: case DepthRenderTargetFormat::kD24S8:
@ -2059,6 +2046,21 @@ GLuint GL4CommandProcessor::GetDepthRenderTarget(
return 0; return 0;
} }
for (auto it = cached_depth_render_targets_.begin();
it != cached_depth_render_targets_.end(); ++it) {
if (it->base == base && it->width == width && it->height == height &&
it->format == format) {
return it->texture;
}
}
cached_depth_render_targets_.push_back(CachedDepthRenderTarget());
auto cached = &cached_depth_render_targets_.back();
cached->base = base;
cached->width = width;
cached->height = height;
cached->format = format;
cached->internal_format = internal_format;
glCreateTextures(GL_TEXTURE_2D, 1, &cached->texture); glCreateTextures(GL_TEXTURE_2D, 1, &cached->texture);
glTextureStorage2D(cached->texture, 1, internal_format, width, height); glTextureStorage2D(cached->texture, 1, internal_format, width, height);

View File

@ -74,6 +74,7 @@ class GL4CommandProcessor : public CommandProcessor {
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
ColorRenderTargetFormat format; ColorRenderTargetFormat format;
GLenum internal_format;
GLuint texture; GLuint texture;
}; };
struct CachedDepthRenderTarget { struct CachedDepthRenderTarget {
@ -81,6 +82,7 @@ class GL4CommandProcessor : public CommandProcessor {
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
DepthRenderTargetFormat format; DepthRenderTargetFormat format;
GLenum internal_format;
GLuint texture; GLuint texture;
}; };
struct CachedPipeline { struct CachedPipeline {