mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
gl: Enforce full image creation argument declaration
- Closes a class of bugs caused by implicit conversion of similar argument types
This commit is contained in:
parent
6c6d03ac5e
commit
99ace42447
12 changed files with 41 additions and 25 deletions
|
@ -119,7 +119,8 @@ namespace rsx
|
|||
RSX_FORMAT_CLASS_DEPTH24_UNORM_X8_PACK32 = 8,
|
||||
RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32 = 16,
|
||||
|
||||
RSX_FORMAT_CLASS_DEPTH_FLOAT_MASK = (RSX_FORMAT_CLASS_DEPTH16_FLOAT | RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32)
|
||||
RSX_FORMAT_CLASS_DEPTH_FLOAT_MASK = (RSX_FORMAT_CLASS_DEPTH16_FLOAT | RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32),
|
||||
RSX_FORMAT_CLASS_DONT_CARE = RSX_FORMAT_CLASS_UNDEFINED,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -229,13 +229,13 @@ void GLGSRender::on_init_thread()
|
|||
|
||||
// Array stream buffer
|
||||
{
|
||||
m_gl_persistent_stream_buffer = std::make_unique<gl::texture>(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI);
|
||||
m_gl_persistent_stream_buffer = std::make_unique<gl::texture>(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI, RSX_FORMAT_CLASS_DONT_CARE);
|
||||
gl_state.bind_texture(GL_STREAM_BUFFER_START + 0, GL_TEXTURE_BUFFER, m_gl_persistent_stream_buffer->id());
|
||||
}
|
||||
|
||||
// Register stream buffer
|
||||
{
|
||||
m_gl_volatile_stream_buffer = std::make_unique<gl::texture>(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI);
|
||||
m_gl_volatile_stream_buffer = std::make_unique<gl::texture>(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI, RSX_FORMAT_CLASS_DONT_CARE);
|
||||
gl_state.bind_texture(GL_STREAM_BUFFER_START + 1, GL_TEXTURE_BUFFER, m_gl_volatile_stream_buffer->id());
|
||||
}
|
||||
|
||||
|
@ -244,19 +244,19 @@ void GLGSRender::on_init_thread()
|
|||
std::array<u32, 8> pixeldata = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// 1D
|
||||
auto tex1D = std::make_unique<gl::texture>(GL_TEXTURE_1D, 1, 1, 1, 1, 1, GL_RGBA8);
|
||||
auto tex1D = std::make_unique<gl::texture>(GL_TEXTURE_1D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex1D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
|
||||
|
||||
// 2D
|
||||
auto tex2D = std::make_unique<gl::texture>(GL_TEXTURE_2D, 1, 1, 1, 1, 1, GL_RGBA8);
|
||||
auto tex2D = std::make_unique<gl::texture>(GL_TEXTURE_2D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex2D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
|
||||
|
||||
// 3D
|
||||
auto tex3D = std::make_unique<gl::texture>(GL_TEXTURE_3D, 1, 1, 1, 1, 1, GL_RGBA8);
|
||||
auto tex3D = std::make_unique<gl::texture>(GL_TEXTURE_3D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex3D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
|
||||
|
||||
// CUBE
|
||||
auto texCUBE = std::make_unique<gl::texture>(GL_TEXTURE_CUBE_MAP, 1, 1, 1, 1, 1, GL_RGBA8);
|
||||
auto texCUBE = std::make_unique<gl::texture>(GL_TEXTURE_CUBE_MAP, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
texCUBE->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
|
||||
|
||||
m_null_textures[GL_TEXTURE_1D] = std::move(tex1D);
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace gl
|
|||
|
||||
gl::texture_view* ui_overlay_renderer::load_simple_image(rsx::overlays::image_info* desc, bool temp_resource, u32 owner_uid)
|
||||
{
|
||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, 1, GL_RGBA8);
|
||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex->copy_from(desc->get_data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
|
||||
|
||||
GLenum remap[] = { GL_RED, GL_ALPHA, GL_BLUE, GL_GREEN };
|
||||
|
@ -301,7 +301,7 @@ namespace gl
|
|||
// Create font file
|
||||
const std::vector<u8> glyph_data = font->get_glyph_data();
|
||||
|
||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8);
|
||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8, RSX_FORMAT_CLASS_COLOR);
|
||||
tex->copy_from(glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {});
|
||||
|
||||
GLenum remap[] = { GL_RED, GL_RED, GL_RED, GL_RED };
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace gl
|
|||
{
|
||||
const auto target = static_cast<GLenum>(visual->get_target());
|
||||
const auto ifmt = static_cast<GLenum>(visual->get_internal_format());
|
||||
g_vis_texture.reset(new texture(target, visual->width(), visual->height(), 1, 1, ifmt, visual->format_class()));
|
||||
g_vis_texture.reset(new texture(target, visual->width(), visual->height(), 1, 1, 1, ifmt, visual->format_class()));
|
||||
glCopyImageSubData(visual->id(), target, 0, 0, 0, 0, g_vis_texture->id(), target, 0, 0, 0, 0, visual->width(), visual->height(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, cons
|
|||
{
|
||||
if (!flip_image || flip_image->size2D() != sizeu{ info->width, info->height })
|
||||
{
|
||||
flip_image = std::make_unique<gl::texture>(GL_TEXTURE_2D, info->width, info->height, 1, 1, 1, expected_format);
|
||||
flip_image = std::make_unique<gl::texture>(GL_TEXTURE_2D, info->width, info->height, 1, 1, 1, expected_format, RSX_FORMAT_CLASS_COLOR);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -466,6 +466,8 @@ void gl::render_target::load_memory(gl::command_context& cmd)
|
|||
msaa_flags = rsx::surface_state_flags::require_unresolve;
|
||||
}
|
||||
}
|
||||
|
||||
state_flags &= ~rsx::surface_state_flags::erase_bkgnd;
|
||||
}
|
||||
|
||||
void gl::render_target::initialize_memory(gl::command_context& cmd, rsx::surface_access access)
|
||||
|
|
|
@ -576,7 +576,7 @@ namespace gl
|
|||
const GLenum internal_format = get_sized_internal_format(gcm_format);
|
||||
const auto format_class = rsx::classify_format(gcm_format);
|
||||
|
||||
return new gl::viewable_image(target, width, height, depth, mipmaps, internal_format, format_class);
|
||||
return new gl::viewable_image(target, width, height, depth, mipmaps, 1, internal_format, format_class);
|
||||
}
|
||||
|
||||
void fill_texture(gl::command_context& cmd, texture* dst, int format,
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace gl
|
|||
|
||||
if (!dst)
|
||||
{
|
||||
std::unique_ptr<temporary_image_t> data = std::make_unique<temporary_image_t>(dst_target, width, height, depth, mipmaps, sized_internal_fmt, rsx::classify_format(gcm_format));
|
||||
std::unique_ptr<temporary_image_t> data = std::make_unique<temporary_image_t>(dst_target, width, height, depth, mipmaps, 1, sized_internal_fmt, rsx::classify_format(gcm_format));
|
||||
dst = data.get();
|
||||
dst->properties_encoding = match_key;
|
||||
m_temporary_surfaces.emplace_back(std::move(data));
|
||||
|
@ -223,7 +223,12 @@ namespace gl
|
|||
{
|
||||
const auto src_bpp = slice.src->pitch() / slice.src->width();
|
||||
const u16 convert_w = u16(slice.src->width() * src_bpp) / dst_bpp;
|
||||
tmp = std::make_unique<texture>(GL_TEXTURE_2D, convert_w, slice.src->height(), 1, 1, static_cast<GLenum>(dst_image->get_internal_format()), dst_image->format_class());
|
||||
tmp = std::make_unique<texture>(
|
||||
GL_TEXTURE_2D,
|
||||
convert_w, slice.src->height(),
|
||||
1, 1, 1,
|
||||
static_cast<GLenum>(dst_image->get_internal_format()),
|
||||
dst_image->format_class());
|
||||
|
||||
src_image = tmp.get();
|
||||
|
||||
|
@ -264,9 +269,17 @@ namespace gl
|
|||
const areai dst_rect = { slice.dst_x, slice.dst_y, slice.dst_x + slice.dst_w, slice.dst_y + slice.dst_h };
|
||||
|
||||
gl::texture* _dst = dst_image;
|
||||
if (src_image->get_internal_format() != dst_image->get_internal_format() || slice.level != 0 || slice.dst_z != 0) [[ unlikely ]]
|
||||
if (src_image->get_internal_format() != dst_image->get_internal_format() ||
|
||||
slice.level != 0 ||
|
||||
slice.dst_z != 0) [[ unlikely ]]
|
||||
{
|
||||
tmp = std::make_unique<texture>(GL_TEXTURE_2D, dst_rect.x2, dst_rect.y2, 1, 1, 1, static_cast<GLenum>(slice.src->get_internal_format()));
|
||||
tmp = std::make_unique<texture>(
|
||||
GL_TEXTURE_2D,
|
||||
dst_rect.x2, dst_rect.y2,
|
||||
1, 1, 1,
|
||||
static_cast<GLenum>(slice.src->get_internal_format()),
|
||||
slice.src->format_class());
|
||||
|
||||
_dst = tmp.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace gl
|
|||
|
||||
if (!scaled_texture)
|
||||
{
|
||||
scaled_texture = std::make_unique<gl::texture>(GL_TEXTURE_2D, real_width, real_height, 1, 1, 1, static_cast<GLenum>(ifmt));
|
||||
scaled_texture = std::make_unique<gl::texture>(GL_TEXTURE_2D, real_width, real_height, 1, 1, 1, static_cast<GLenum>(ifmt), vram_texture->format_class());
|
||||
}
|
||||
|
||||
const bool linear_interp = is_depth_texture() ? false : true;
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace gl
|
|||
if (static_cast<gl::texture::internal_format>(internal_fmt) != src->get_internal_format())
|
||||
{
|
||||
const u16 internal_width = static_cast<u16>(src->width() * xfer_info.src_scaling_hint);
|
||||
typeless_src = std::make_unique<texture>(GL_TEXTURE_2D, internal_width, src->height(), 1, 1, 1, internal_fmt);
|
||||
typeless_src = std::make_unique<texture>(GL_TEXTURE_2D, internal_width, src->height(), 1, 1, 1, internal_fmt, RSX_FORMAT_CLASS_DONT_CARE);
|
||||
copy_typeless(cmd, typeless_src.get(), src);
|
||||
|
||||
real_src = typeless_src.get();
|
||||
|
@ -85,7 +85,7 @@ namespace gl
|
|||
if (static_cast<gl::texture::internal_format>(internal_fmt) != dst->get_internal_format())
|
||||
{
|
||||
const auto internal_width = static_cast<u16>(dst->width() * xfer_info.dst_scaling_hint);
|
||||
typeless_dst = std::make_unique<texture>(GL_TEXTURE_2D, internal_width, dst->height(), 1, 1, 1, internal_fmt);
|
||||
typeless_dst = std::make_unique<texture>(GL_TEXTURE_2D, internal_width, dst->height(), 1, 1, 1, internal_fmt, RSX_FORMAT_CLASS_DONT_CARE);
|
||||
copy_typeless(cmd, typeless_dst.get(), dst);
|
||||
|
||||
real_dst = typeless_dst.get();
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace gl
|
|||
|
||||
void texture::copy_from(const void* src, texture::format format, texture::type type, int level, const coord3u region, const pixel_unpack_settings& pixel_settings)
|
||||
{
|
||||
ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
|
||||
pixel_settings.apply();
|
||||
|
||||
|
@ -220,7 +220,7 @@ namespace gl
|
|||
|
||||
void texture::copy_from(buffer& buf, u32 gl_format_type, u32 offset, u32 length)
|
||||
{
|
||||
ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
|
||||
if (get_target() != target::textureBuffer)
|
||||
fmt::throw_exception("OpenGL error: texture cannot copy from buffer");
|
||||
|
@ -235,7 +235,7 @@ namespace gl
|
|||
|
||||
void texture::copy_to(void* dst, texture::format format, texture::type type, int level, const coord3u& region, const pixel_pack_settings& pixel_settings) const
|
||||
{
|
||||
ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures.");
|
||||
|
||||
pixel_settings.apply();
|
||||
const auto& caps = get_driver_caps();
|
||||
|
@ -257,7 +257,7 @@ namespace gl
|
|||
{
|
||||
// Worst case scenario. For some reason, EXT_dsa does not have glGetTextureSubImage
|
||||
const auto target_ = static_cast<GLenum>(m_target);
|
||||
texture tmp{ target_, region.width, region.height, region.depth, 1, 1, static_cast<GLenum>(m_internal_format) };
|
||||
texture tmp{ target_, region.width, region.height, region.depth, 1, 1, static_cast<GLenum>(m_internal_format), m_format_class };
|
||||
glCopyImageSubData(m_id, target_, level, region.x, region.y, region.z, tmp.id(), target_, 0, 0, 0, 0,
|
||||
region.width, region.height, region.depth);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace gl
|
|||
texture(const texture&) = delete;
|
||||
texture(texture&& texture_) = delete;
|
||||
|
||||
texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLubyte samples, GLenum sized_format, rsx::format_class format_class = rsx::RSX_FORMAT_CLASS_UNDEFINED);
|
||||
texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLubyte samples, GLenum sized_format, rsx::format_class format_class);
|
||||
virtual ~texture();
|
||||
|
||||
// Getters/setters
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace gl
|
|||
{
|
||||
return std::make_unique<gl::viewable_image>(
|
||||
GL_TEXTURE_2D,
|
||||
output_w, output_h, 1, 1,
|
||||
output_w, output_h, 1, 1, 1,
|
||||
GL_RGBA8, RSX_FORMAT_CLASS_COLOR);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue