mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 17:11:23 +00:00
rsx: Separate uint depth formats from float depth formats
This commit is contained in:
parent
faaf28b41d
commit
a5ac5a9861
@ -839,6 +839,18 @@ u8 get_format_block_size_in_bytes(rsx::surface_color_format format)
|
||||
}
|
||||
}
|
||||
|
||||
u8 get_format_block_size_in_bytes(rsx::surface_depth_format2 format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format2::z24s8_uint:
|
||||
case rsx::surface_depth_format2::z24s8_float:
|
||||
return 4;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
u8 get_format_sample_count(rsx::surface_antialiasing antialias)
|
||||
{
|
||||
switch (antialias)
|
||||
@ -856,6 +868,18 @@ u8 get_format_sample_count(rsx::surface_antialiasing antialias)
|
||||
}
|
||||
}
|
||||
|
||||
bool is_depth_stencil_format(rsx::surface_depth_format2 format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format2::z24s8_uint:
|
||||
case rsx::surface_depth_format2::z24s8_float:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of texel lines decoded in one pitch-length number of bytes
|
||||
*/
|
||||
@ -1047,15 +1071,24 @@ std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_color_format format)
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_depth_format format)
|
||||
std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_depth_format2 format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16:
|
||||
case rsx::surface_depth_format2::z16_uint:
|
||||
return{ CELL_GCM_TEXTURE_DEPTH16, true };
|
||||
case rsx::surface_depth_format::z24s8:
|
||||
case rsx::surface_depth_format2::z24s8_uint:
|
||||
return{ CELL_GCM_TEXTURE_DEPTH24_D8, true };
|
||||
case rsx::surface_depth_format2::z16_float :
|
||||
return{ CELL_GCM_TEXTURE_DEPTH16_FLOAT, true };
|
||||
case rsx::surface_depth_format2::z24s8_float:
|
||||
return{ CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT, true };
|
||||
default:
|
||||
ASSUME(0);
|
||||
}
|
||||
}
|
||||
|
||||
u32 get_max_depth_value(rsx::surface_depth_format2 format)
|
||||
{
|
||||
return get_format_block_size_in_bytes(format) == 2 ? 0xFFFF : 0xFFFFFF;
|
||||
}
|
||||
|
@ -135,8 +135,11 @@ texture_memory_info upload_texture_subresource(gsl::span<std::byte> dst_buffer,
|
||||
u8 get_format_block_size_in_bytes(int format);
|
||||
u8 get_format_block_size_in_texel(int format);
|
||||
u8 get_format_block_size_in_bytes(rsx::surface_color_format format);
|
||||
u8 get_format_block_size_in_bytes(rsx::surface_depth_format2 format);
|
||||
|
||||
u8 get_format_sample_count(rsx::surface_antialiasing antialias);
|
||||
u32 get_max_depth_value(rsx::surface_depth_format2 format);
|
||||
bool is_depth_stencil_format(rsx::surface_depth_format2 format);
|
||||
|
||||
/**
|
||||
* Returns number of texel rows encoded in one pitch-length line of bytes
|
||||
@ -163,4 +166,4 @@ u32 get_remap_encoding(const std::pair<std::array<u8, 4>, std::array<u8, 4>>& re
|
||||
* Get gcm texel layout. Returns <format, byteswapped>
|
||||
*/
|
||||
std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_color_format format);
|
||||
std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_depth_format format);
|
||||
std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_depth_format2 format);
|
||||
|
@ -650,7 +650,7 @@ namespace rsx
|
||||
surface_type bind_address_as_depth_stencil(
|
||||
command_list_type command_list,
|
||||
u32 address,
|
||||
surface_depth_format depth_format,
|
||||
surface_depth_format2 depth_format,
|
||||
surface_antialiasing antialias,
|
||||
size_t width, size_t height, size_t pitch,
|
||||
Args&&... extra_params)
|
||||
@ -658,7 +658,7 @@ namespace rsx
|
||||
return bind_surface_address<true>(
|
||||
command_list, address, depth_format, antialias,
|
||||
width, height, pitch,
|
||||
depth_format == rsx::surface_depth_format::z16? 2 : 4,
|
||||
get_format_block_size_in_bytes(depth_format),
|
||||
std::forward<Args>(extra_params)...);
|
||||
}
|
||||
|
||||
@ -670,7 +670,7 @@ namespace rsx
|
||||
template <typename ...Args>
|
||||
void prepare_render_target(
|
||||
command_list_type command_list,
|
||||
surface_color_format color_format, surface_depth_format depth_format,
|
||||
surface_color_format color_format, surface_depth_format2 depth_format,
|
||||
u32 clip_horizontal_reg, u32 clip_vertical_reg,
|
||||
surface_target set_surface_target,
|
||||
surface_antialiasing antialias,
|
||||
|
@ -149,7 +149,7 @@ namespace rsx
|
||||
union
|
||||
{
|
||||
rsx::surface_color_format gcm_color_format;
|
||||
rsx::surface_depth_format gcm_depth_format;
|
||||
rsx::surface_depth_format2 gcm_depth_format;
|
||||
}
|
||||
format_info;
|
||||
|
||||
@ -263,16 +263,17 @@ namespace rsx
|
||||
format_info.gcm_color_format = format;
|
||||
}
|
||||
|
||||
void set_format(rsx::surface_depth_format format)
|
||||
void set_format(rsx::surface_depth_format2 format)
|
||||
{
|
||||
format_info.gcm_depth_format = format;
|
||||
}
|
||||
|
||||
void set_depth_render_mode(bool integer)
|
||||
{
|
||||
if (is_depth_surface())
|
||||
if (format >= rsx::surface_depth_format2::z16_float)
|
||||
{
|
||||
format_class = (integer) ? format_type::depth_uint : format_type::depth_float;
|
||||
format_class = rsx::format_type::depth_float;
|
||||
}
|
||||
else
|
||||
{
|
||||
format_class = rsx::format_type::depth_uint;
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +282,7 @@ namespace rsx
|
||||
return format_info.gcm_color_format;
|
||||
}
|
||||
|
||||
rsx::surface_depth_format get_surface_depth_format() const
|
||||
rsx::surface_depth_format2 get_surface_depth_format() const
|
||||
{
|
||||
return format_info.gcm_depth_format;
|
||||
}
|
||||
|
@ -7,19 +7,6 @@
|
||||
|
||||
#define DUMP_VERTEX_DATA 0
|
||||
|
||||
namespace
|
||||
{
|
||||
u32 get_max_depth_value(rsx::surface_depth_format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16: return 0xFFFF;
|
||||
case rsx::surface_depth_format::z24s8: return 0xFFFFFF;
|
||||
}
|
||||
fmt::throw_exception("Unknown depth format" HERE);
|
||||
}
|
||||
}
|
||||
|
||||
u64 GLGSRender::get_cycles()
|
||||
{
|
||||
return thread_ctrl::get_cycles(static_cast<named_thread<GLGSRender>&>(*this));
|
||||
@ -510,21 +497,21 @@ void GLGSRender::clear_surface(u32 arg)
|
||||
rsx::method_registers.scissor_height() < rsx::method_registers.surface_clip_height();
|
||||
|
||||
bool update_color = false, update_z = false;
|
||||
rsx::surface_depth_format surface_depth_format = rsx::method_registers.surface_depth_fmt();
|
||||
rsx::surface_depth_format2 surface_depth_format = rsx::method_registers.surface_depth_fmt();
|
||||
|
||||
if (auto ds = std::get<1>(m_rtts.m_bound_depth_stencil); arg & 0x3)
|
||||
{
|
||||
if (arg & 0x1)
|
||||
{
|
||||
u32 max_depth_value = get_max_depth_value(surface_depth_format);
|
||||
u32 clear_depth = rsx::method_registers.z_clear_value(surface_depth_format == rsx::surface_depth_format::z24s8);
|
||||
u32 clear_depth = rsx::method_registers.z_clear_value(is_depth_stencil_format(surface_depth_format));
|
||||
|
||||
gl_state.depth_mask(GL_TRUE);
|
||||
gl_state.clear_depth(f32(clear_depth) / max_depth_value);
|
||||
mask |= GLenum(gl::buffers::depth);
|
||||
}
|
||||
|
||||
if (surface_depth_format == rsx::surface_depth_format::z24s8)
|
||||
if (is_depth_stencil_format(surface_depth_format))
|
||||
{
|
||||
if (arg & 0x2)
|
||||
{
|
||||
|
@ -631,12 +631,11 @@ namespace gl
|
||||
|
||||
switch (const auto fmt = dst->get_internal_format())
|
||||
{
|
||||
case texture::internal_format::depth:
|
||||
case texture::internal_format::depth16:
|
||||
case texture::internal_format::depth32f:
|
||||
clear_mask = GL_DEPTH_BUFFER_BIT;
|
||||
attachment = GL_DEPTH_ATTACHMENT;
|
||||
break;
|
||||
case texture::internal_format::depth_stencil:
|
||||
case texture::internal_format::depth24_stencil8:
|
||||
case texture::internal_format::depth32f_stencil8:
|
||||
clear_mask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
||||
|
@ -1473,11 +1473,9 @@ namespace gl
|
||||
bgr = GL_BGR,
|
||||
bgra = GL_BGRA,
|
||||
|
||||
stencil = GL_STENCIL_INDEX,
|
||||
stencil8 = GL_STENCIL_INDEX8,
|
||||
depth = GL_DEPTH_COMPONENT,
|
||||
depth16 = GL_DEPTH_COMPONENT16,
|
||||
depth_stencil = GL_DEPTH_STENCIL,
|
||||
depth32f = GL_DEPTH_COMPONENT32F,
|
||||
depth24_stencil8 = GL_DEPTH24_STENCIL8,
|
||||
depth32f_stencil8 = GL_DEPTH32F_STENCIL8,
|
||||
|
||||
|
@ -66,18 +66,23 @@ color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_forma
|
||||
}
|
||||
}
|
||||
|
||||
depth_format rsx::internals::surface_depth_format_to_gl(rsx::surface_depth_format depth_format)
|
||||
depth_format rsx::internals::surface_depth_format_to_gl(rsx::surface_depth_format2 depth_format)
|
||||
{
|
||||
switch (depth_format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16:
|
||||
case rsx::surface_depth_format2::z16_uint:
|
||||
return{ ::gl::texture::type::ushort, ::gl::texture::format::depth, ::gl::texture::internal_format::depth16 };
|
||||
case rsx::surface_depth_format2::z16_float:
|
||||
return{ ::gl::texture::type::f16, ::gl::texture::format::depth, ::gl::texture::internal_format::depth32f };
|
||||
|
||||
case rsx::surface_depth_format::z24s8:
|
||||
case rsx::surface_depth_format2::z24s8_uint:
|
||||
if (g_cfg.video.force_high_precision_z_buffer && ::gl::get_driver_caps().ARB_depth_buffer_float_supported)
|
||||
return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth32f_stencil8 };
|
||||
else
|
||||
return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth24_stencil8 };
|
||||
case rsx::surface_depth_format2::z24s8_float:
|
||||
// TODO, requires separate aspect transfer for reading
|
||||
return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth32f_stencil8 };
|
||||
|
||||
default:
|
||||
fmt::throw_exception("Unsupported depth format 0x%x" HERE, static_cast<u32>(depth_format));
|
||||
@ -215,7 +220,6 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
|
||||
{
|
||||
auto ds = std::get<1>(m_rtts.m_bound_depth_stencil);
|
||||
depth_stencil_target = ds->id();
|
||||
ds->set_depth_render_mode(!m_framebuffer_layout.depth_float);
|
||||
|
||||
verify("Pitch mismatch!" HERE), std::get<1>(m_rtts.m_bound_depth_stencil)->get_rsx_pitch() == m_framebuffer_layout.actual_zeta_pitch;
|
||||
|
||||
@ -224,8 +228,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
|
||||
m_depth_surface_info.width = m_framebuffer_layout.width;
|
||||
m_depth_surface_info.height = m_framebuffer_layout.height;
|
||||
m_depth_surface_info.depth_format = m_framebuffer_layout.depth_format;
|
||||
m_depth_surface_info.depth_buffer_float = m_framebuffer_layout.depth_float;
|
||||
m_depth_surface_info.bpp = (m_framebuffer_layout.depth_format == rsx::surface_depth_format::z16? 2 : 4);
|
||||
m_depth_surface_info.bpp = get_format_block_size_in_bytes(m_framebuffer_layout.depth_format);
|
||||
m_depth_surface_info.samples = samples;
|
||||
|
||||
m_gl_texture_cache.notify_surface_changed(m_depth_surface_info.get_memory_range(m_framebuffer_layout.aa_factors));
|
||||
@ -279,7 +282,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
|
||||
|
||||
if (depth_stencil_target)
|
||||
{
|
||||
if (m_framebuffer_layout.depth_format == rsx::surface_depth_format::z24s8)
|
||||
if (is_depth_stencil_format(m_framebuffer_layout.depth_format))
|
||||
{
|
||||
m_draw_fbo->depth_stencil = depth_stencil_target;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace rsx
|
||||
namespace internals
|
||||
{
|
||||
color_format surface_color_format_to_gl(rsx::surface_color_format color_format);
|
||||
depth_format surface_depth_format_to_gl(rsx::surface_depth_format depth_format);
|
||||
depth_format surface_depth_format_to_gl(rsx::surface_depth_format2 depth_format);
|
||||
u8 get_pixel_size(rsx::surface_depth_format format);
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ struct gl_render_target_traits
|
||||
static
|
||||
std::unique_ptr<gl::render_target> create_new_surface(
|
||||
u32 address,
|
||||
rsx::surface_depth_format surface_depth_format,
|
||||
rsx::surface_depth_format2 surface_depth_format,
|
||||
size_t width, size_t height, size_t pitch,
|
||||
rsx::surface_antialiasing antialias
|
||||
)
|
||||
@ -178,12 +178,7 @@ struct gl_render_target_traits
|
||||
result->set_aa_mode(antialias);
|
||||
result->set_surface_dimensions(static_cast<u16>(width), static_cast<u16>(height), static_cast<u16>(pitch));
|
||||
result->set_format(surface_depth_format);
|
||||
|
||||
u16 native_pitch = static_cast<u16>(width) * 2 * result->samples_x;
|
||||
if (surface_depth_format == rsx::surface_depth_format::z24s8)
|
||||
native_pitch *= 2;
|
||||
|
||||
result->set_native_pitch(native_pitch);
|
||||
result->set_native_pitch(static_cast<u16>(width) * get_format_block_size_in_bytes(surface_depth_format) * result->samples_x);
|
||||
|
||||
std::array<GLenum, 4> native_layout = { GL_RED, GL_RED, GL_RED, GL_RED };
|
||||
result->set_native_component_layout(native_layout);
|
||||
@ -333,7 +328,7 @@ struct gl_render_target_traits
|
||||
static
|
||||
bool surface_matches_properties(
|
||||
const std::unique_ptr<gl::render_target> &surface,
|
||||
rsx::surface_depth_format format,
|
||||
rsx::surface_depth_format2 format,
|
||||
size_t width, size_t height,
|
||||
rsx::surface_antialiasing antialias,
|
||||
bool check_refs = false)
|
||||
|
@ -960,13 +960,12 @@ namespace gl
|
||||
case CELL_GCM_TEXTURE_DEPTH24_D8:
|
||||
case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT:
|
||||
return (ifmt == gl::texture::internal_format::depth24_stencil8 ||
|
||||
ifmt == gl::texture::internal_format::depth32f_stencil8 ||
|
||||
ifmt == gl::texture::internal_format::depth_stencil);
|
||||
ifmt == gl::texture::internal_format::depth32f_stencil8);
|
||||
case CELL_GCM_TEXTURE_X16:
|
||||
case CELL_GCM_TEXTURE_DEPTH16:
|
||||
case CELL_GCM_TEXTURE_DEPTH16_FLOAT:
|
||||
return (ifmt == gl::texture::internal_format::depth16 ||
|
||||
ifmt == gl::texture::internal_format::depth);
|
||||
ifmt == gl::texture::internal_format::depth32f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1011,7 +1011,6 @@ namespace rsx
|
||||
|
||||
layout.color_format = rsx::method_registers.surface_color();
|
||||
layout.depth_format = rsx::method_registers.surface_depth_fmt();
|
||||
layout.depth_float = rsx::method_registers.depth_buffer_float_enabled();
|
||||
layout.target = rsx::method_registers.surface_color_target();
|
||||
|
||||
const auto mrt_buffers = rsx::utility::get_rtt_indexes(layout.target);
|
||||
@ -1020,9 +1019,9 @@ namespace rsx
|
||||
const u32 aa_factor_v = (aa_mode == rsx::surface_antialiasing::center_1_sample || aa_mode == rsx::surface_antialiasing::diagonal_centered_2_samples) ? 1 : 2;
|
||||
const u8 sample_count = get_format_sample_count(aa_mode);
|
||||
|
||||
const auto depth_texel_size = (layout.depth_format == rsx::surface_depth_format::z16 ? 2 : 4) * aa_factor_u;
|
||||
const auto depth_texel_size = get_format_block_size_in_bytes(layout.depth_format) * aa_factor_u;
|
||||
const auto color_texel_size = get_format_block_size_in_bytes(layout.color_format) * aa_factor_u;
|
||||
const bool stencil_test_enabled = layout.depth_format == rsx::surface_depth_format::z24s8 && rsx::method_registers.stencil_test_enabled();
|
||||
const bool stencil_test_enabled = is_depth_stencil_format(layout.depth_format) && rsx::method_registers.stencil_test_enabled();
|
||||
const bool depth_test_enabled = rsx::method_registers.depth_test_enabled();
|
||||
|
||||
// Check write masks
|
||||
@ -1301,7 +1300,6 @@ namespace rsx
|
||||
{
|
||||
if (layout.zeta_address == m_depth_surface_info.address &&
|
||||
layout.depth_format == m_depth_surface_info.depth_format &&
|
||||
layout.depth_float == m_depth_surface_info.depth_buffer_float &&
|
||||
sample_count == m_depth_surface_info.samples)
|
||||
{
|
||||
// Same target is reused
|
||||
@ -1324,7 +1322,7 @@ namespace rsx
|
||||
{
|
||||
if (!m_framebuffer_layout.zeta_write_enabled &&
|
||||
rsx::method_registers.stencil_test_enabled() &&
|
||||
m_framebuffer_layout.depth_format == rsx::surface_depth_format::z24s8)
|
||||
is_depth_stencil_format(m_framebuffer_layout.depth_format))
|
||||
{
|
||||
// Check if stencil data is modified
|
||||
auto mask = rsx::method_registers.stencil_mask();
|
||||
@ -1378,7 +1376,7 @@ namespace rsx
|
||||
}
|
||||
|
||||
// Check if stencil read is enabled
|
||||
if (m_framebuffer_layout.depth_format == rsx::surface_depth_format::z24s8 &&
|
||||
if (is_depth_stencil_format(m_framebuffer_layout.depth_format) &&
|
||||
rsx::method_registers.stencil_test_enabled())
|
||||
{
|
||||
return true;
|
||||
|
@ -340,11 +340,10 @@ namespace rsx
|
||||
bool zeta_write_enabled;
|
||||
rsx::surface_target target;
|
||||
rsx::surface_color_format color_format;
|
||||
rsx::surface_depth_format depth_format;
|
||||
rsx::surface_depth_format2 depth_format;
|
||||
rsx::surface_antialiasing aa_mode;
|
||||
rsx::surface_raster_type raster_type;
|
||||
u32 aa_factors[2];
|
||||
bool depth_float;
|
||||
bool ignore_change;
|
||||
};
|
||||
|
||||
|
@ -42,17 +42,25 @@ namespace vk
|
||||
return result;
|
||||
}
|
||||
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format)
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format2 format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16: return VK_FORMAT_D16_UNORM;
|
||||
case rsx::surface_depth_format::z24s8:
|
||||
case rsx::surface_depth_format2::z16_uint:
|
||||
return VK_FORMAT_D16_UNORM;
|
||||
case rsx::surface_depth_format2::z16_float:
|
||||
return VK_FORMAT_D32_SFLOAT;
|
||||
case rsx::surface_depth_format2::z24s8_uint:
|
||||
{
|
||||
if (support.d24_unorm_s8) return VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
if (support.d32_sfloat_s8) return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
fmt::throw_exception("No hardware support for z24s8" HERE);
|
||||
}
|
||||
case rsx::surface_depth_format2::z24s8_float:
|
||||
{
|
||||
if (support.d32_sfloat_s8) return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
fmt::throw_exception("No hardware support for z24s8_float" HERE);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace vk
|
||||
|
||||
VkBorderColor get_border_color(u32 color);
|
||||
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format);
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format2 format);
|
||||
VkFormat get_compatible_sampler_format(const gpu_formats_support &support, u32 format);
|
||||
VkFormat get_compatible_srgb_format(VkFormat rgb_format);
|
||||
u8 get_format_texel_width(VkFormat format);
|
||||
|
@ -7,35 +7,6 @@
|
||||
#include "VKResourceManager.h"
|
||||
#include "VKCommandStream.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
u32 get_max_depth_value(rsx::surface_depth_format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16: return 0xFFFF;
|
||||
case rsx::surface_depth_format::z24s8: return 0xFFFFFF;
|
||||
default:
|
||||
ASSUME(0);
|
||||
break;
|
||||
}
|
||||
fmt::throw_exception("Unknown depth format" HERE);
|
||||
}
|
||||
|
||||
u8 get_pixel_size(rsx::surface_depth_format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case rsx::surface_depth_format::z16: return 2;
|
||||
case rsx::surface_depth_format::z24s8: return 4;
|
||||
default:
|
||||
ASSUME(0);
|
||||
break;
|
||||
}
|
||||
fmt::throw_exception("Unknown depth format" HERE);
|
||||
}
|
||||
}
|
||||
|
||||
namespace vk
|
||||
{
|
||||
VkCompareOp get_compare_func(rsx::comparison_function op, bool reverse_direction = false);
|
||||
@ -1089,7 +1060,7 @@ void VKGSRender::clear_surface(u32 mask)
|
||||
{
|
||||
u32 max_depth_value = get_max_depth_value(surface_depth_format);
|
||||
|
||||
u32 clear_depth = rsx::method_registers.z_clear_value(surface_depth_format == rsx::surface_depth_format::z24s8);
|
||||
u32 clear_depth = rsx::method_registers.z_clear_value(is_depth_stencil_format(surface_depth_format));
|
||||
float depth_clear = static_cast<float>(clear_depth) / max_depth_value;
|
||||
|
||||
depth_stencil_clear_values.depthStencil.depth = depth_clear;
|
||||
@ -1098,7 +1069,7 @@ void VKGSRender::clear_surface(u32 mask)
|
||||
depth_stencil_mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
}
|
||||
|
||||
if (surface_depth_format == rsx::surface_depth_format::z24s8)
|
||||
if (is_depth_stencil_format(surface_depth_format))
|
||||
{
|
||||
if (mask & 0x2)
|
||||
{
|
||||
@ -2067,8 +2038,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
|
||||
m_depth_surface_info.width = m_framebuffer_layout.width;
|
||||
m_depth_surface_info.height = m_framebuffer_layout.height;
|
||||
m_depth_surface_info.depth_format = m_framebuffer_layout.depth_format;
|
||||
m_depth_surface_info.depth_buffer_float = m_framebuffer_layout.depth_float;
|
||||
m_depth_surface_info.bpp = (m_framebuffer_layout.depth_format == rsx::surface_depth_format::z16? 2 : 4);
|
||||
m_depth_surface_info.bpp = get_format_block_size_in_bytes(m_framebuffer_layout.depth_format);
|
||||
m_depth_surface_info.samples = samples;
|
||||
}
|
||||
|
||||
@ -2095,7 +2065,6 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
|
||||
if (std::get<0>(m_rtts.m_bound_depth_stencil) != 0)
|
||||
{
|
||||
auto ds = std::get<1>(m_rtts.m_bound_depth_stencil);
|
||||
ds->set_depth_render_mode(!m_framebuffer_layout.depth_float);
|
||||
m_fbo_images.push_back(ds);
|
||||
|
||||
m_depth_surface_info.address = m_framebuffer_layout.zeta_address;
|
||||
|
@ -692,7 +692,7 @@ namespace rsx
|
||||
|
||||
static std::unique_ptr<vk::render_target> create_new_surface(
|
||||
u32 address,
|
||||
surface_depth_format format,
|
||||
surface_depth_format2 format,
|
||||
size_t width, size_t height, size_t pitch,
|
||||
rsx::surface_antialiasing antialias,
|
||||
vk::render_device &device, vk::command_buffer& cmd)
|
||||
@ -738,11 +738,7 @@ namespace rsx
|
||||
ds->memory_usage_flags= rsx::surface_usage_flags::attachment;
|
||||
ds->state_flags = rsx::surface_state_flags::erase_bkgnd;
|
||||
ds->native_component_map = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R };
|
||||
|
||||
ds->native_pitch = static_cast<u16>(width) * 2 * ds->samples_x;
|
||||
if (format == rsx::surface_depth_format::z24s8)
|
||||
ds->native_pitch *= 2;
|
||||
|
||||
ds->native_pitch = static_cast<u16>(width) * get_format_block_size_in_bytes(format) * ds->samples_x;
|
||||
ds->rsx_pitch = static_cast<u16>(pitch);
|
||||
ds->surface_width = static_cast<u16>(width);
|
||||
ds->surface_height = static_cast<u16>(height);
|
||||
@ -911,7 +907,7 @@ namespace rsx
|
||||
|
||||
static bool surface_matches_properties(
|
||||
const std::unique_ptr<vk::render_target> &surface,
|
||||
surface_depth_format format,
|
||||
surface_depth_format2 format,
|
||||
size_t width, size_t height,
|
||||
rsx::surface_antialiasing antialias,
|
||||
bool check_refs = false)
|
||||
|
@ -53,12 +53,53 @@ namespace rsx
|
||||
|
||||
enum class surface_depth_format : u8
|
||||
{
|
||||
z16, // unsigned 16 bits depth
|
||||
z24s8, // unsigned 24 bits depth + 8 bits stencil
|
||||
z16, // typeless 16 bits depth
|
||||
z24s8, // typeless 24 bits depth + 8 bits stencil
|
||||
};
|
||||
|
||||
enum class surface_depth_format2 : u8
|
||||
{
|
||||
z16_uint, // unsigned 16 bits depth
|
||||
z24s8_uint, // unsigned 24 bits depth + 8 bits stencil
|
||||
z16_float, // floating point 16 bits depth
|
||||
z24s8_float, // floating point 24 bits depth + 8 bits stencil
|
||||
};
|
||||
|
||||
surface_depth_format to_surface_depth_format(u8 in);
|
||||
|
||||
constexpr
|
||||
bool operator == (surface_depth_format2 rhs, surface_depth_format lhs)
|
||||
{
|
||||
switch (lhs)
|
||||
{
|
||||
case surface_depth_format::z16:
|
||||
return (rhs == surface_depth_format2::z16_uint || rhs == surface_depth_format2::z16_float);
|
||||
case surface_depth_format::z24s8:
|
||||
return (rhs == surface_depth_format2::z24s8_uint || rhs == surface_depth_format2::z24s8_float);
|
||||
default:
|
||||
ASSUME(0);
|
||||
}
|
||||
}
|
||||
|
||||
// GCC requires every operator declared explicitly
|
||||
constexpr
|
||||
bool operator == (surface_depth_format rhs, surface_depth_format2 lhs)
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
constexpr
|
||||
bool operator != (surface_depth_format2 rhs, surface_depth_format lhs)
|
||||
{
|
||||
return !(rhs == lhs);
|
||||
}
|
||||
|
||||
constexpr
|
||||
bool operator != (surface_depth_format rhs, surface_depth_format2 lhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
enum class surface_raster_type : u8
|
||||
{
|
||||
undefined = 0,
|
||||
|
@ -1310,9 +1310,17 @@ namespace rsx
|
||||
return decode<NV4097_SET_SURFACE_FORMAT>().color_fmt();
|
||||
}
|
||||
|
||||
surface_depth_format surface_depth_fmt() const
|
||||
surface_depth_format2 surface_depth_fmt() const
|
||||
{
|
||||
return decode<NV4097_SET_SURFACE_FORMAT>().depth_fmt();
|
||||
const auto base_fmt = decode<NV4097_SET_SURFACE_FORMAT>().depth_fmt();
|
||||
if (!depth_buffer_float_enabled()) [[likely]]
|
||||
{
|
||||
return static_cast<surface_depth_format2>(base_fmt);
|
||||
}
|
||||
|
||||
return base_fmt == surface_depth_format::z16 ?
|
||||
surface_depth_format2::z16_float :
|
||||
surface_depth_format2::z24s8_float;
|
||||
}
|
||||
|
||||
surface_raster_type surface_type() const
|
||||
@ -1640,57 +1648,57 @@ namespace rsx
|
||||
registers[NV4097_SET_TRANSFORM_PROGRAM_LOAD] = value;
|
||||
}
|
||||
|
||||
u32 transform_constant_load()
|
||||
u32 transform_constant_load() const
|
||||
{
|
||||
return registers[NV4097_SET_TRANSFORM_CONSTANT_LOAD];
|
||||
}
|
||||
|
||||
u32 transform_branch_bits()
|
||||
u32 transform_branch_bits() const
|
||||
{
|
||||
return registers[NV4097_SET_TRANSFORM_BRANCH_BITS];
|
||||
}
|
||||
|
||||
u16 msaa_sample_mask()
|
||||
u16 msaa_sample_mask() const
|
||||
{
|
||||
return decode<NV4097_SET_ANTI_ALIASING_CONTROL>().msaa_sample_mask();
|
||||
}
|
||||
|
||||
bool msaa_enabled()
|
||||
bool msaa_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_ANTI_ALIASING_CONTROL>().msaa_enabled();
|
||||
}
|
||||
|
||||
bool msaa_alpha_to_coverage_enabled()
|
||||
bool msaa_alpha_to_coverage_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_ANTI_ALIASING_CONTROL>().msaa_alpha_to_coverage();
|
||||
}
|
||||
|
||||
bool msaa_alpha_to_one_enabled()
|
||||
bool msaa_alpha_to_one_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_ANTI_ALIASING_CONTROL>().msaa_alpha_to_one();
|
||||
}
|
||||
|
||||
bool depth_clamp_enabled()
|
||||
bool depth_clamp_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_ZMIN_MAX_CONTROL>().depth_clamp_enabled();
|
||||
}
|
||||
|
||||
bool depth_clip_enabled()
|
||||
bool depth_clip_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_ZMIN_MAX_CONTROL>().depth_clip_enabled();
|
||||
}
|
||||
|
||||
bool depth_clip_ignore_w()
|
||||
bool depth_clip_ignore_w() const
|
||||
{
|
||||
return decode<NV4097_SET_ZMIN_MAX_CONTROL>().depth_clip_ignore_w();
|
||||
}
|
||||
|
||||
bool framebuffer_srgb_enabled()
|
||||
bool framebuffer_srgb_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_SHADER_PACKER>().srgb_output_enabled();
|
||||
}
|
||||
|
||||
bool depth_buffer_float_enabled()
|
||||
bool depth_buffer_float_enabled() const
|
||||
{
|
||||
return decode<NV4097_SET_CONTROL0>().depth_float();
|
||||
}
|
||||
|
@ -114,8 +114,7 @@ namespace rsx
|
||||
u32 pitch = 0;
|
||||
|
||||
rsx::surface_color_format color_format;
|
||||
rsx::surface_depth_format depth_format;
|
||||
bool depth_buffer_float;
|
||||
rsx::surface_depth_format2 depth_format;
|
||||
|
||||
u16 width = 0;
|
||||
u16 height = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user