Code style fixes #1

This commit is contained in:
DHrpcs3 2016-01-20 16:23:25 +03:00
parent 685d5d3ea3
commit 7972cb5bdc
21 changed files with 583 additions and 581 deletions

View file

@ -50,12 +50,12 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_
switch (vertex_array_desc.type) switch (vertex_array_desc.type)
{ {
case Vertex_base_type::ub: case vertex_base_type::ub:
memcpy(dst, src, vertex_array_desc.size); memcpy(dst, src, vertex_array_desc.size);
break; break;
case Vertex_base_type::s1: case vertex_base_type::s1:
case Vertex_base_type::sf: case vertex_base_type::sf:
{ {
auto* c_src = (const be_t<u16>*)src; auto* c_src = (const be_t<u16>*)src;
u16* c_dst = (u16*)dst; u16* c_dst = (u16*)dst;
@ -69,9 +69,9 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_
break; break;
} }
case Vertex_base_type::f: case vertex_base_type::f:
case Vertex_base_type::s32k: case vertex_base_type::s32k:
case Vertex_base_type::ub256: case vertex_base_type::ub256:
{ {
auto* c_src = (const be_t<u32>*)src; auto* c_src = (const be_t<u32>*)src;
u32* c_dst = (u32*)dst; u32* c_dst = (u32*)dst;
@ -82,7 +82,7 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_
} }
break; break;
} }
case Vertex_base_type::cmp: case vertex_base_type::cmp:
{ {
auto* c_src = (const be_t<u32>*)src; auto* c_src = (const be_t<u32>*)src;
const auto& decoded_vector = decode_cmp_vector(*c_src); const auto& decoded_vector = decode_cmp_vector(*c_src);
@ -244,21 +244,21 @@ std::tuple<T, T> expand_indexed_quads(gsl::span<to_be_t<const T>> src, gsl::span
} }
// Only handle quads and triangle fan now // Only handle quads and triangle fan now
bool is_primitive_native(Primitive_type m_draw_mode) bool is_primitive_native(primitive_type draw_mode)
{ {
switch (m_draw_mode) switch (draw_mode)
{ {
case Primitive_type::points: case primitive_type::points:
case Primitive_type::lines: case primitive_type::lines:
case Primitive_type::line_loop: case primitive_type::line_loop:
case Primitive_type::line_strip: case primitive_type::line_strip:
case Primitive_type::triangles: case primitive_type::triangles:
case Primitive_type::triangle_strip: case primitive_type::triangle_strip:
case Primitive_type::quad_strip: case primitive_type::quad_strip:
return true; return true;
case Primitive_type::polygon: case primitive_type::polygon:
case Primitive_type::triangle_fan: case primitive_type::triangle_fan:
case Primitive_type::quads: case primitive_type::quads:
return false; return false;
} }
throw new EXCEPTION("Wrong primitive type"); throw new EXCEPTION("Wrong primitive type");
@ -269,41 +269,41 @@ bool is_primitive_native(Primitive_type m_draw_mode)
* see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334 * see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334
*/ */
size_t get_index_count(Primitive_type m_draw_mode, unsigned initial_index_count) size_t get_index_count(primitive_type draw_mode, unsigned initial_index_count)
{ {
// Index count // Index count
if (is_primitive_native(m_draw_mode)) if (is_primitive_native(draw_mode))
return initial_index_count; return initial_index_count;
switch (m_draw_mode) switch (draw_mode)
{ {
case Primitive_type::polygon: case primitive_type::polygon:
case Primitive_type::triangle_fan: case primitive_type::triangle_fan:
return (initial_index_count - 2) * 3; return (initial_index_count - 2) * 3;
case Primitive_type::quads: case primitive_type::quads:
return (6 * initial_index_count) / 4; return (6 * initial_index_count) / 4;
default: default:
return 0; return 0;
} }
} }
size_t get_index_type_size(Index_array_type type) size_t get_index_type_size(index_array_type type)
{ {
switch (type) switch (type)
{ {
case Index_array_type::unsigned_16b: return 2; case index_array_type::unsigned_16b: return 2;
case Index_array_type::unsigned_32b: return 4; case index_array_type::unsigned_32b: return 4;
} }
throw new EXCEPTION("Wrong index type"); throw new EXCEPTION("Wrong index type");
} }
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, Primitive_type draw_mode, unsigned first, unsigned count) void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, primitive_type draw_mode, unsigned first, unsigned count)
{ {
unsigned short *typedDst = (unsigned short *)(dst); unsigned short *typedDst = (unsigned short *)(dst);
switch (draw_mode) switch (draw_mode)
{ {
case Primitive_type::triangle_fan: case primitive_type::triangle_fan:
case Primitive_type::polygon: case primitive_type::polygon:
for (unsigned i = 0; i < (count - 2); i++) for (unsigned i = 0; i < (count - 2); i++)
{ {
typedDst[3 * i] = first; typedDst[3 * i] = first;
@ -311,7 +311,7 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst,
typedDst[3 * i + 2] = i + 2; typedDst[3 * i + 2] = i + 2;
} }
return; return;
case Primitive_type::quads: case primitive_type::quads:
for (unsigned i = 0; i < count / 4; i++) for (unsigned i = 0; i < count / 4; i++)
{ {
// First triangle // First triangle
@ -324,13 +324,13 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst,
typedDst[6 * i + 5] = 4 * i + first; typedDst[6 * i + 5] = 4 * i + first;
} }
return; return;
case Primitive_type::points: case primitive_type::points:
case Primitive_type::lines: case primitive_type::lines:
case Primitive_type::line_loop: case primitive_type::line_loop:
case Primitive_type::line_strip: case primitive_type::line_strip:
case Primitive_type::triangles: case primitive_type::triangles:
case Primitive_type::triangle_strip: case primitive_type::triangle_strip:
case Primitive_type::quad_strip: case primitive_type::quad_strip:
throw new EXCEPTION("Native primitive type doesn't require expansion"); throw new EXCEPTION("Native primitive type doesn't require expansion");
} }
} }
@ -338,10 +338,10 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst,
// TODO: Unify indexed and non indexed primitive expansion ? // TODO: Unify indexed and non indexed primitive expansion ?
template<typename T> template<typename T>
std::tuple<T, T> write_index_array_data_to_buffer_impl(gsl::span<T, gsl::dynamic_range> dst, Primitive_type m_draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments) std::tuple<T, T> write_index_array_data_to_buffer_impl(gsl::span<T, gsl::dynamic_range> dst, primitive_type draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments)
{ {
u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf);
Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
u32 type_size = gsl::narrow<u32>(get_index_type_size(type)); u32 type_size = gsl::narrow<u32>(get_index_type_size(type));
@ -362,40 +362,40 @@ std::tuple<T, T> write_index_array_data_to_buffer_impl(gsl::span<T, gsl::dynamic
u32 count = std::get<0>(first_count_arguments.back()) + std::get<1>(first_count_arguments.back()) - first; u32 count = std::get<0>(first_count_arguments.back()) + std::get<1>(first_count_arguments.back()) - first;
auto ptr = vm::ps3::_ptr<const T>(address + first * type_size); auto ptr = vm::ps3::_ptr<const T>(address + first * type_size);
switch (m_draw_mode) switch (draw_mode)
{ {
case Primitive_type::points: case primitive_type::points:
case Primitive_type::lines: case primitive_type::lines:
case Primitive_type::line_loop: case primitive_type::line_loop:
case Primitive_type::line_strip: case primitive_type::line_strip:
case Primitive_type::triangles: case primitive_type::triangles:
case Primitive_type::triangle_strip: case primitive_type::triangle_strip:
case Primitive_type::quad_strip: case primitive_type::quad_strip:
return upload_untouched<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); return upload_untouched<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index);
case Primitive_type::polygon: case primitive_type::polygon:
case Primitive_type::triangle_fan: case primitive_type::triangle_fan:
return expand_indexed_triangle_fan<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); return expand_indexed_triangle_fan<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index);
case Primitive_type::quads: case primitive_type::quads:
return expand_indexed_quads<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index); return expand_indexed_quads<T>({ ptr, count }, dst, is_primitive_restart_enabled, primitive_restart_index);
} }
throw new EXCEPTION("Unknow draw mode"); throw new EXCEPTION("Unknow draw mode");
} }
std::tuple<u32, u32> write_index_array_data_to_buffer(gsl::span<u32, gsl::dynamic_range> dst, Primitive_type m_draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments) std::tuple<u32, u32> write_index_array_data_to_buffer(gsl::span<u32, gsl::dynamic_range> dst, primitive_type draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments)
{ {
return write_index_array_data_to_buffer_impl(dst, m_draw_mode, first_count_arguments); return write_index_array_data_to_buffer_impl(dst, draw_mode, first_count_arguments);
} }
std::tuple<u16, u16> write_index_array_data_to_buffer(gsl::span<u16, gsl::dynamic_range> dst, Primitive_type m_draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments) std::tuple<u16, u16> write_index_array_data_to_buffer(gsl::span<u16, gsl::dynamic_range> dst, primitive_type draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments)
{ {
return write_index_array_data_to_buffer_impl(dst, m_draw_mode, first_count_arguments); return write_index_array_data_to_buffer_impl(dst, draw_mode, first_count_arguments);
} }
std::tuple<u32, u32> write_index_array_data_to_buffer_untouched(gsl::span<u32, gsl::dynamic_range> dst, const std::vector<std::pair<u32, u32> > &first_count_arguments) std::tuple<u32, u32> write_index_array_data_to_buffer_untouched(gsl::span<u32, gsl::dynamic_range> dst, const std::vector<std::pair<u32, u32> > &first_count_arguments)
{ {
u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf);
Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
u32 type_size = gsl::narrow<u32>(get_index_type_size(type)); u32 type_size = gsl::narrow<u32>(get_index_type_size(type));
bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]; bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE];
@ -418,7 +418,7 @@ std::tuple<u32, u32> write_index_array_data_to_buffer_untouched(gsl::span<u32, g
std::tuple<u16, u16> write_index_array_data_to_buffer_untouched(gsl::span<u16, gsl::dynamic_range> dst, const std::vector<std::pair<u32, u32> > &first_count_arguments) std::tuple<u16, u16> write_index_array_data_to_buffer_untouched(gsl::span<u16, gsl::dynamic_range> dst, const std::vector<std::pair<u32, u32> > &first_count_arguments)
{ {
u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf);
Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
u32 type_size = gsl::narrow<u32>(get_index_type_size(type)); u32 type_size = gsl::narrow<u32>(get_index_type_size(type));
bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]; bool is_primitive_restart_enabled = !!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE];

View file

@ -11,25 +11,25 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_
/* /*
* If primitive mode is not supported and need to be emulated (using an index buffer) returns false. * If primitive mode is not supported and need to be emulated (using an index buffer) returns false.
*/ */
bool is_primitive_native(Primitive_type m_draw_mode); bool is_primitive_native(primitive_type m_draw_mode);
/** /**
* Returns a fixed index count for emulated primitive, otherwise returns initial_index_count * Returns a fixed index count for emulated primitive, otherwise returns initial_index_count
*/ */
size_t get_index_count(Primitive_type m_draw_mode, unsigned initial_index_count); size_t get_index_count(primitive_type m_draw_mode, unsigned initial_index_count);
/** /**
* Returns index type size in byte * Returns index type size in byte
*/ */
size_t get_index_type_size(Index_array_type type); size_t get_index_type_size(index_array_type type);
/** /**
* Write count indexes using (first, first + count) ranges. * Write count indexes using (first, first + count) ranges.
* Returns min/max index found during the process. * Returns min/max index found during the process.
* The function expands index buffer for non native primitive type. * The function expands index buffer for non native primitive type.
*/ */
std::tuple<u32, u32> write_index_array_data_to_buffer(gsl::span<u32, gsl::dynamic_range> dst, Primitive_type m_draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments); std::tuple<u32, u32> write_index_array_data_to_buffer(gsl::span<u32, gsl::dynamic_range> dst, primitive_type draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments);
std::tuple<u16, u16> write_index_array_data_to_buffer(gsl::span<u16, gsl::dynamic_range> dst, Primitive_type m_draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments); std::tuple<u16, u16> write_index_array_data_to_buffer(gsl::span<u16, gsl::dynamic_range> dst, primitive_type draw_mode, const std::vector<std::pair<u32, u32> > &first_count_arguments);
/** /**
* Doesn't expand index * Doesn't expand index
@ -40,7 +40,7 @@ std::tuple<u16, u16> write_index_array_data_to_buffer_untouched(gsl::span<u16, g
/** /**
* Write index data needed to emulate non indexed non native primitive mode. * Write index data needed to emulate non indexed non native primitive mode.
*/ */
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, Primitive_type m_draw_mode, unsigned first, unsigned count); void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, primitive_type draw_mode, unsigned first, unsigned count);
/** /**
* Stream a 128 bits vector to dst. * Stream a 128 bits vector to dst.

View file

@ -5,60 +5,60 @@ namespace rsx
{ {
namespace utility namespace utility
{ {
std::vector<u8> get_rtt_indexes(Surface_target color_target) std::vector<u8> get_rtt_indexes(surface_target color_target)
{ {
switch (color_target) switch (color_target)
{ {
case Surface_target::none: return{}; case surface_target::none: return{};
case Surface_target::surface_a: return{ 0 }; case surface_target::surface_a: return{ 0 };
case Surface_target::surface_b: return{ 1 }; case surface_target::surface_b: return{ 1 };
case Surface_target::surfaces_a_b: return{ 0, 1 }; case surface_target::surfaces_a_b: return{ 0, 1 };
case Surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; case surface_target::surfaces_a_b_c: return{ 0, 1, 2 };
case Surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; case surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 };
} }
throw EXCEPTION("Wrong color_target"); throw EXCEPTION("Wrong color_target");
} }
size_t get_aligned_pitch(Surface_color_format format, u32 width) size_t get_aligned_pitch(surface_color_format format, u32 width)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::b8: return align(width, 256); case surface_color_format::b8: return align(width, 256);
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::r5g6b5: return align(width * 2, 256); case surface_color_format::r5g6b5: return align(width * 2, 256);
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
case Surface_color_format::a8r8g8b8: return align(width * 4, 256); case surface_color_format::a8r8g8b8: return align(width * 4, 256);
case Surface_color_format::w16z16y16x16: return align(width * 8, 256); case surface_color_format::w16z16y16x16: return align(width * 8, 256);
case Surface_color_format::w32z32y32x32: return align(width * 16, 256); case surface_color_format::w32z32y32x32: return align(width * 16, 256);
} }
throw EXCEPTION("Unknow color surface format"); throw EXCEPTION("Unknow color surface format");
} }
size_t get_packed_pitch(Surface_color_format format, u32 width) size_t get_packed_pitch(surface_color_format format, u32 width)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::b8: return width; case surface_color_format::b8: return width;
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::r5g6b5: return width * 2; case surface_color_format::r5g6b5: return width * 2;
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
case Surface_color_format::a8r8g8b8: return width * 4; case surface_color_format::a8r8g8b8: return width * 4;
case Surface_color_format::w16z16y16x16: return width * 8; case surface_color_format::w16z16y16x16: return width * 8;
case Surface_color_format::w32z32y32x32: return width * 16; case surface_color_format::w32z32y32x32: return width * 16;
} }
throw EXCEPTION("Unknow color surface format"); throw EXCEPTION("Unknow color surface format");
} }

View file

@ -7,9 +7,9 @@ namespace rsx
{ {
namespace utility namespace utility
{ {
std::vector<u8> get_rtt_indexes(Surface_target color_target); std::vector<u8> get_rtt_indexes(surface_target color_target);
size_t get_aligned_pitch(Surface_color_format format, u32 width); size_t get_aligned_pitch(surface_color_format format, u32 width);
size_t get_packed_pitch(Surface_color_format format, u32 width); size_t get_packed_pitch(surface_color_format format, u32 width);
} }
/** /**
@ -86,7 +86,7 @@ namespace rsx
gsl::not_null<surface_type> bind_address_as_render_targets( gsl::not_null<surface_type> bind_address_as_render_targets(
command_list_type command_list, command_list_type command_list,
u32 address, u32 address,
Surface_color_format surface_color_format, size_t width, size_t height, surface_color_format color_format, size_t width, size_t height,
Args&&... extra_params) Args&&... extra_params)
{ {
auto It = m_render_targets_storage.find(address); auto It = m_render_targets_storage.find(address);
@ -96,7 +96,7 @@ namespace rsx
if (It != m_render_targets_storage.end()) if (It != m_render_targets_storage.end())
{ {
surface_storage_type &rtt = It->second; surface_storage_type &rtt = It->second;
if (Traits::rtt_has_format_width_height(rtt, surface_color_format, width, height)) if (Traits::rtt_has_format_width_height(rtt, color_format, width, height))
{ {
Traits::prepare_rtt_for_drawing(command_list, Traits::get(rtt)); Traits::prepare_rtt_for_drawing(command_list, Traits::get(rtt));
return Traits::get(rtt); return Traits::get(rtt);
@ -105,7 +105,7 @@ namespace rsx
m_render_targets_storage.erase(address); m_render_targets_storage.erase(address);
} }
m_render_targets_storage[address] = Traits::create_new_surface(address, surface_color_format, width, height, std::forward<Args>(extra_params)...); m_render_targets_storage[address] = Traits::create_new_surface(address, color_format, width, height, std::forward<Args>(extra_params)...);
return Traits::get(m_render_targets_storage[address]); return Traits::get(m_render_targets_storage[address]);
} }
@ -113,14 +113,14 @@ namespace rsx
gsl::not_null<surface_type> bind_address_as_depth_stencil( gsl::not_null<surface_type> bind_address_as_depth_stencil(
command_list_type command_list, command_list_type command_list,
u32 address, u32 address,
Surface_depth_format surface_depth_format, size_t width, size_t height, surface_depth_format depth_format, size_t width, size_t height,
Args&&... extra_params) Args&&... extra_params)
{ {
auto It = m_depth_stencil_storage.find(address); auto It = m_depth_stencil_storage.find(address);
if (It != m_depth_stencil_storage.end()) if (It != m_depth_stencil_storage.end())
{ {
surface_storage_type &ds = It->second; surface_storage_type &ds = It->second;
if (Traits::ds_has_format_width_height(ds, surface_depth_format, width, height)) if (Traits::ds_has_format_width_height(ds, depth_format, width, height))
{ {
Traits::prepare_ds_for_drawing(command_list, Traits::get(ds)); Traits::prepare_ds_for_drawing(command_list, Traits::get(ds));
return Traits::get(ds); return Traits::get(ds);
@ -129,7 +129,7 @@ namespace rsx
m_depth_stencil_storage.erase(address); m_depth_stencil_storage.erase(address);
} }
m_depth_stencil_storage[address] = Traits::create_new_surface(address, surface_depth_format, width, height, std::forward<Args>(extra_params)...); m_depth_stencil_storage[address] = Traits::create_new_surface(address, depth_format, width, height, std::forward<Args>(extra_params)...);
return Traits::get(m_depth_stencil_storage[address]); return Traits::get(m_depth_stencil_storage[address]);
} }
public: public:
@ -142,7 +142,7 @@ namespace rsx
command_list_type command_list, command_list_type command_list,
u32 set_surface_format_reg, u32 set_surface_format_reg,
u32 clip_horizontal_reg, u32 clip_vertical_reg, u32 clip_horizontal_reg, u32 clip_vertical_reg,
Surface_target set_surface_target, surface_target set_surface_target,
const std::array<u32, 4> &surface_addresses, u32 address_z, const std::array<u32, 4> &surface_addresses, u32 address_z,
Args&&... extra_params) Args&&... extra_params)
{ {
@ -151,8 +151,8 @@ namespace rsx
u32 clip_x = clip_horizontal_reg; u32 clip_x = clip_horizontal_reg;
u32 clip_y = clip_vertical_reg; u32 clip_y = clip_vertical_reg;
Surface_color_format color_format = to_surface_color_format(set_surface_format_reg & 0x1f); surface_color_format color_format = to_surface_color_format(set_surface_format_reg & 0x1f);
Surface_depth_format depth_format = to_surface_depth_format((set_surface_format_reg >> 5) & 0x7); surface_depth_format depth_format = to_surface_depth_format((set_surface_format_reg >> 5) & 0x7);
// Make previous RTTs sampleable // Make previous RTTs sampleable
for (std::tuple<u32, surface_type> &rtt : m_bound_render_targets) for (std::tuple<u32, surface_type> &rtt : m_bound_render_targets)
@ -216,7 +216,7 @@ namespace rsx
*/ */
template <typename... Args> template <typename... Args>
std::array<std::vector<gsl::byte>, 4> get_render_targets_data( std::array<std::vector<gsl::byte>, 4> get_render_targets_data(
Surface_color_format surface_color_format, size_t width, size_t height, surface_color_format color_format, size_t width, size_t height,
Args&& ...args Args&& ...args
) )
{ {
@ -230,7 +230,7 @@ namespace rsx
surface_type surface_resource = std::get<1>(m_bound_render_targets[i]); surface_type surface_resource = std::get<1>(m_bound_render_targets[i]);
download_data[i] = std::move( download_data[i] = std::move(
Traits::issue_download_command(surface_resource, surface_color_format, width, height, std::forward<Args&&>(args)...) Traits::issue_download_command(surface_resource, color_format, width, height, std::forward<Args&&>(args)...)
); );
} }
@ -244,50 +244,50 @@ namespace rsx
gsl::span<const gsl::byte> raw_src = Traits::map_downloaded_buffer(download_data[i], std::forward<Args&&>(args)...); gsl::span<const gsl::byte> raw_src = Traits::map_downloaded_buffer(download_data[i], std::forward<Args&&>(args)...);
size_t src_pitch = utility::get_aligned_pitch(surface_color_format, gsl::narrow<u32>(width)); size_t src_pitch = utility::get_aligned_pitch(color_format, gsl::narrow<u32>(width));
size_t dst_pitch = utility::get_packed_pitch(surface_color_format, gsl::narrow<u32>(width)); size_t dst_pitch = utility::get_packed_pitch(color_format, gsl::narrow<u32>(width));
result[i].resize(dst_pitch * height); result[i].resize(dst_pitch * height);
// Note: MSVC + GSL doesn't support span<byte> -> span<T> for non const span atm // Note: MSVC + GSL doesn't support span<byte> -> span<T> for non const span atm
// thus manual conversion // thus manual conversion
switch (surface_color_format) switch (color_format)
{ {
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::a8r8g8b8: case surface_color_format::a8r8g8b8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
{ {
gsl::span<be_t<u32>> dst_span{ (be_t<u32>*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(be_t<u32>)) }; gsl::span<be_t<u32>> dst_span{ (be_t<u32>*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(be_t<u32>)) };
copy_pitched_src_to_dst(dst_span, gsl::as_span<const u32>(raw_src), src_pitch, width, height); copy_pitched_src_to_dst(dst_span, gsl::as_span<const u32>(raw_src), src_pitch, width, height);
break; break;
} }
case Surface_color_format::b8: case surface_color_format::b8:
{ {
gsl::span<u8> dst_span{ (u8*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u8)) }; gsl::span<u8> dst_span{ (u8*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u8)) };
copy_pitched_src_to_dst(dst_span, gsl::as_span<const u8>(raw_src), src_pitch, width, height); copy_pitched_src_to_dst(dst_span, gsl::as_span<const u8>(raw_src), src_pitch, width, height);
break; break;
} }
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::r5g6b5: case surface_color_format::r5g6b5:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
{ {
gsl::span<be_t<u16>> dst_span{ (be_t<u16>*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(be_t<u16>)) }; gsl::span<be_t<u16>> dst_span{ (be_t<u16>*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(be_t<u16>)) };
copy_pitched_src_to_dst(dst_span, gsl::as_span<const u16>(raw_src), src_pitch, width, height); copy_pitched_src_to_dst(dst_span, gsl::as_span<const u16>(raw_src), src_pitch, width, height);
break; break;
} }
// Note : may require some big endian swap // Note : may require some big endian swap
case Surface_color_format::w32z32y32x32: case surface_color_format::w32z32y32x32:
{ {
gsl::span<u128> dst_span{ (u128*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u128)) }; gsl::span<u128> dst_span{ (u128*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u128)) };
copy_pitched_src_to_dst(dst_span, gsl::as_span<const u128>(raw_src), src_pitch, width, height); copy_pitched_src_to_dst(dst_span, gsl::as_span<const u128>(raw_src), src_pitch, width, height);
break; break;
} }
case Surface_color_format::w16z16y16x16: case surface_color_format::w16z16y16x16:
{ {
gsl::span<u64> dst_span{ (u64*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u64)) }; gsl::span<u64> dst_span{ (u64*)result[i].data(), gsl::narrow<int>(dst_pitch * width / sizeof(u64)) };
copy_pitched_src_to_dst(dst_span, gsl::as_span<const u64>(raw_src), src_pitch, width, height); copy_pitched_src_to_dst(dst_span, gsl::as_span<const u64>(raw_src), src_pitch, width, height);
@ -305,7 +305,7 @@ namespace rsx
*/ */
template <typename... Args> template <typename... Args>
std::array<std::vector<gsl::byte>, 2> get_depth_stencil_data( std::array<std::vector<gsl::byte>, 2> get_depth_stencil_data(
Surface_depth_format surface_depth_format, size_t width, size_t height, surface_depth_format depth_format, size_t width, size_t height,
Args&& ...args Args&& ...args
) )
{ {
@ -315,18 +315,18 @@ namespace rsx
size_t row_pitch = align(width * 4, 256); size_t row_pitch = align(width * 4, 256);
download_buffer_object stencil_data = {}; download_buffer_object stencil_data = {};
download_buffer_object depth_data = Traits::issue_depth_download_command(std::get<1>(m_bound_depth_stencil), surface_depth_format, width, height, std::forward<Args&&>(args)...); download_buffer_object depth_data = Traits::issue_depth_download_command(std::get<1>(m_bound_depth_stencil), depth_format, width, height, std::forward<Args&&>(args)...);
if (surface_depth_format == Surface_depth_format::z24s8) if (depth_format == surface_depth_format::z24s8)
stencil_data = std::move(Traits::issue_stencil_download_command(std::get<1>(m_bound_depth_stencil), width, height, std::forward<Args&&>(args)...)); stencil_data = std::move(Traits::issue_stencil_download_command(std::get<1>(m_bound_depth_stencil), width, height, std::forward<Args&&>(args)...));
gsl::span<const gsl::byte> depth_buffer_raw_src = Traits::map_downloaded_buffer(depth_data, std::forward<Args&&>(args)...); gsl::span<const gsl::byte> depth_buffer_raw_src = Traits::map_downloaded_buffer(depth_data, std::forward<Args&&>(args)...);
if (surface_depth_format == Surface_depth_format::z16) if (depth_format == surface_depth_format::z16)
{ {
result[0].resize(width * height * 2); result[0].resize(width * height * 2);
gsl::span<u16> dest{ (u16*)result[0].data(), gsl::narrow<int>(width * height) }; gsl::span<u16> dest{ (u16*)result[0].data(), gsl::narrow<int>(width * height) };
copy_pitched_src_to_dst(dest, gsl::as_span<const u16>(depth_buffer_raw_src), row_pitch, width, height); copy_pitched_src_to_dst(dest, gsl::as_span<const u16>(depth_buffer_raw_src), row_pitch, width, height);
} }
if (surface_depth_format == Surface_depth_format::z24s8) if (depth_format == surface_depth_format::z24s8)
{ {
result[0].resize(width * height * 4); result[0].resize(width * height * 4);
gsl::span<u32> dest{ (u32*)result[0].data(), gsl::narrow<int>(width * height) }; gsl::span<u32> dest{ (u32*)result[0].data(), gsl::narrow<int>(width * height) };
@ -334,7 +334,7 @@ namespace rsx
} }
Traits::unmap_downloaded_buffer(depth_data, std::forward<Args&&>(args)...); Traits::unmap_downloaded_buffer(depth_data, std::forward<Args&&>(args)...);
if (surface_depth_format == Surface_depth_format::z16) if (depth_format == surface_depth_format::z16)
return result; return result;
gsl::span<const gsl::byte> stencil_buffer_raw_src = Traits::map_downloaded_buffer(stencil_data, std::forward<Args&&>(args)...); gsl::span<const gsl::byte> stencil_buffer_raw_src = Traits::map_downloaded_buffer(stencil_data, std::forward<Args&&>(args)...);

View file

@ -260,7 +260,7 @@ std::tuple<D3D12_INDEX_BUFFER_VIEW, size_t> D3D12GSRender::generate_index_buffer
std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12GraphicsCommandList *command_list) std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12GraphicsCommandList *command_list)
{ {
if (draw_command == Draw_command::draw_command_inlined_array) if (draw_command == rsx::draw_command::inlined_array)
{ {
size_t vertex_count; size_t vertex_count;
D3D12_VERTEX_BUFFER_VIEW vertex_buffer_view; D3D12_VERTEX_BUFFER_VIEW vertex_buffer_view;
@ -277,7 +277,7 @@ std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G
return std::make_tuple(true, index_count); return std::make_tuple(true, index_count);
} }
if (draw_command == Draw_command::draw_command_array) if (draw_command == rsx::draw_command::array)
{ {
const std::vector<D3D12_VERTEX_BUFFER_VIEW> &vertex_buffer_views = upload_vertex_attributes(first_count_commands); const std::vector<D3D12_VERTEX_BUFFER_VIEW> &vertex_buffer_views = upload_vertex_attributes(first_count_commands);
command_list->IASetVertexBuffers(0, (UINT)vertex_buffer_views.size(), vertex_buffer_views.data()); command_list->IASetVertexBuffers(0, (UINT)vertex_buffer_views.size(), vertex_buffer_views.data());
@ -298,7 +298,7 @@ std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G
return std::make_tuple(true, index_count); return std::make_tuple(true, index_count);
} }
assert(draw_command == Draw_command::draw_command_indexed); assert(draw_command == rsx::draw_command::indexed);
// Index count // Index count
size_t index_count = 0; size_t index_count = 0;
@ -306,7 +306,7 @@ std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G
index_count += pair.second; index_count += pair.second;
index_count = get_index_count(draw_mode, gsl::narrow<int>(index_count)); index_count = get_index_count(draw_mode, gsl::narrow<int>(index_count));
Index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
size_t index_size = get_index_type_size(indexed_type); size_t index_size = get_index_type_size(indexed_type);
// Alloc // Alloc
@ -316,13 +316,13 @@ std::tuple<bool, size_t> D3D12GSRender::upload_and_set_vertex_index_data(ID3D12G
void *mapped_buffer = m_buffer_data.map<void>(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size)); void *mapped_buffer = m_buffer_data.map<void>(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
u32 min_index, max_index; u32 min_index, max_index;
if (indexed_type == Index_array_type::unsigned_16b) if (indexed_type == index_array_type::unsigned_16b)
{ {
gsl::span<u16> dst = { (u16*)mapped_buffer, gsl::narrow<int>(buffer_size / index_size) }; gsl::span<u16> dst = { (u16*)mapped_buffer, gsl::narrow<int>(buffer_size / index_size) };
std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands); std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands);
} }
if (indexed_type == Index_array_type::unsigned_32b) if (indexed_type == index_array_type::unsigned_32b)
{ {
gsl::span<u32> dst = { (u32*)mapped_buffer, gsl::narrow<int>(buffer_size / index_size) }; gsl::span<u32> dst = { (u32*)mapped_buffer, gsl::narrow<int>(buffer_size / index_size) };
std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands); std::tie(min_index, max_index) = write_index_array_data_to_buffer(dst, draw_mode, first_count_commands);

View file

@ -262,99 +262,99 @@ D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter)
return D3D12_ENCODE_BASIC_FILTER(min, mag, mip, D3D12_FILTER_REDUCTION_TYPE_STANDARD); return D3D12_ENCODE_BASIC_FILTER(min, mag, mip, D3D12_FILTER_REDUCTION_TYPE_STANDARD);
} }
D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(Primitive_type draw_mode) D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(primitive_type draw_mode)
{ {
switch (draw_mode) switch (draw_mode)
{ {
case Primitive_type::points: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; case primitive_type::points: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
case Primitive_type::lines: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; case primitive_type::lines: return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
case Primitive_type::line_loop: return D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; case primitive_type::line_loop: return D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ;
case Primitive_type::line_strip: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; case primitive_type::line_strip: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
case Primitive_type::triangles: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case primitive_type::triangles: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case Primitive_type::triangle_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; case primitive_type::triangle_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
case Primitive_type::triangle_fan: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case primitive_type::triangle_fan: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case Primitive_type::quads: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case primitive_type::quads: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case Primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case Primitive_type::polygon: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case primitive_type::polygon: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
} }
throw EXCEPTION("Invalid draw mode (0x%x)", draw_mode); throw EXCEPTION("Invalid draw mode (0x%x)", draw_mode);
} }
D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(Primitive_type draw_mode) D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(primitive_type draw_mode)
{ {
switch (draw_mode) switch (draw_mode)
{ {
case Primitive_type::points: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; case primitive_type::points: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
case Primitive_type::lines: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; case primitive_type::lines: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
case Primitive_type::line_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; case primitive_type::line_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
case Primitive_type::triangles: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::triangles: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::triangle_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::triangle_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::triangle_fan: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::triangle_fan: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::quads: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::quads: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::quad_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::quad_strip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
case Primitive_type::line_loop: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; case primitive_type::line_loop: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
} }
throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", draw_mode); throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", draw_mode);
} }
DXGI_FORMAT get_color_surface_format(Surface_color_format format) DXGI_FORMAT get_color_surface_format(surface_color_format format)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::r5g6b5: return DXGI_FORMAT_B5G6R5_UNORM; case surface_color_format::r5g6b5: return DXGI_FORMAT_B5G6R5_UNORM;
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
return DXGI_FORMAT_B8G8R8X8_UNORM; //BIT.TRIP Runner2 use this return DXGI_FORMAT_B8G8R8X8_UNORM; //BIT.TRIP Runner2 use this
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::a8r8g8b8: return DXGI_FORMAT_R8G8B8A8_UNORM; case surface_color_format::a8r8g8b8: return DXGI_FORMAT_R8G8B8A8_UNORM;
case Surface_color_format::b8: return DXGI_FORMAT_R8_UNORM; case surface_color_format::b8: return DXGI_FORMAT_R8_UNORM;
case Surface_color_format::g8b8: return DXGI_FORMAT_R8G8_UNORM; case surface_color_format::g8b8: return DXGI_FORMAT_R8G8_UNORM;
case Surface_color_format::w16z16y16x16: return DXGI_FORMAT_R16G16B16A16_FLOAT; case surface_color_format::w16z16y16x16: return DXGI_FORMAT_R16G16B16A16_FLOAT;
case Surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT; case surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case Surface_color_format::x32: return DXGI_FORMAT_R32_FLOAT; case surface_color_format::x32: return DXGI_FORMAT_R32_FLOAT;
} }
throw EXCEPTION("Invalid format (0x%x)", format); throw EXCEPTION("Invalid format (0x%x)", format);
} }
DXGI_FORMAT get_depth_stencil_surface_format(Surface_depth_format format) DXGI_FORMAT get_depth_stencil_surface_format(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; case surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM;
case Surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; case surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT;
} }
throw EXCEPTION("Invalid format (0x%x)", format); throw EXCEPTION("Invalid format (0x%x)", format);
} }
DXGI_FORMAT get_depth_stencil_surface_clear_format(Surface_depth_format format) DXGI_FORMAT get_depth_stencil_surface_clear_format(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; case surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM;
case Surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; case surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT;
} }
throw EXCEPTION("Invalid format (0x%x)", format); throw EXCEPTION("Invalid format (0x%x)", format);
} }
DXGI_FORMAT get_depth_stencil_typeless_surface_format(Surface_depth_format format) DXGI_FORMAT get_depth_stencil_typeless_surface_format(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS; case surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS;
case Surface_depth_format::z24s8: return DXGI_FORMAT_R24G8_TYPELESS; case surface_depth_format::z24s8: return DXGI_FORMAT_R24G8_TYPELESS;
} }
throw EXCEPTION("Invalid format (0x%x)", format); throw EXCEPTION("Invalid format (0x%x)", format);
} }
DXGI_FORMAT get_depth_samplable_surface_format(Surface_depth_format format) DXGI_FORMAT get_depth_samplable_surface_format(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM; case surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM;
case Surface_depth_format::z24s8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; case surface_depth_format::z24s8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
} }
throw EXCEPTION("Invalid format (0x%x)", format); throw EXCEPTION("Invalid format (0x%x)", format);
} }
@ -370,21 +370,21 @@ BOOL get_front_face_ccw(u32 ffv)
throw EXCEPTION("Invalid front face value (0x%x)", ffv); throw EXCEPTION("Invalid front face value (0x%x)", ffv);
} }
DXGI_FORMAT get_index_type(Index_array_type index_type) DXGI_FORMAT get_index_type(index_array_type index_type)
{ {
switch (index_type) switch (index_type)
{ {
case Index_array_type::unsigned_16b: return DXGI_FORMAT_R16_UINT; case index_array_type::unsigned_16b: return DXGI_FORMAT_R16_UINT;
case Index_array_type::unsigned_32b: return DXGI_FORMAT_R32_UINT; case index_array_type::unsigned_32b: return DXGI_FORMAT_R32_UINT;
} }
throw EXCEPTION("Invalid index_type (0x%x)", index_type); throw EXCEPTION("Invalid index_type (0x%x)", index_type);
} }
DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size) DXGI_FORMAT get_vertex_attribute_format(vertex_base_type type, u8 size)
{ {
switch (type) switch (type)
{ {
case Vertex_base_type::s1: case vertex_base_type::s1:
{ {
switch (size) switch (size)
{ {
@ -395,7 +395,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::f: case vertex_base_type::f:
{ {
switch (size) switch (size)
{ {
@ -406,7 +406,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::sf: case vertex_base_type::sf:
{ {
switch (size) switch (size)
{ {
@ -417,7 +417,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::ub: case vertex_base_type::ub:
{ {
switch (size) switch (size)
{ {
@ -428,7 +428,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::s32k: case vertex_base_type::s32k:
{ {
switch (size) switch (size)
{ {
@ -439,7 +439,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::cmp: case vertex_base_type::cmp:
{ {
switch (size) switch (size)
{ {
@ -450,7 +450,7 @@ DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size)
} }
break; break;
} }
case Vertex_base_type::ub256: case vertex_base_type::ub256:
{ {
switch (size) switch (size)
{ {

View file

@ -56,37 +56,37 @@ D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter);
/** /**
* Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY
*/ */
D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(Primitive_type draw_mode); D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(primitive_type draw_mode);
/** /**
* Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY_TYPE * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY_TYPE
*/ */
D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(Primitive_type draw_mode); D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(primitive_type draw_mode);
/** /**
* Convert color surface format to DXGI_FORMAT * Convert color surface format to DXGI_FORMAT
*/ */
DXGI_FORMAT get_color_surface_format(Surface_color_format format); DXGI_FORMAT get_color_surface_format(surface_color_format format);
/** /**
* Convert depth stencil surface format to DXGI_FORMAT * Convert depth stencil surface format to DXGI_FORMAT
*/ */
DXGI_FORMAT get_depth_stencil_surface_format(Surface_depth_format format); DXGI_FORMAT get_depth_stencil_surface_format(surface_depth_format format);
/** /**
*Convert depth stencil surface format to DXGI_FORMAT suited for clear value *Convert depth stencil surface format to DXGI_FORMAT suited for clear value
*/ */
DXGI_FORMAT get_depth_stencil_surface_clear_format(Surface_depth_format format); DXGI_FORMAT get_depth_stencil_surface_clear_format(surface_depth_format format);
/** /**
* Convert depth surface format to a typeless DXGI_FORMAT * Convert depth surface format to a typeless DXGI_FORMAT
*/ */
DXGI_FORMAT get_depth_stencil_typeless_surface_format(Surface_depth_format format); DXGI_FORMAT get_depth_stencil_typeless_surface_format(surface_depth_format format);
/** /**
* Convert depth surface format to a DXGI_FORMAT that can be depth sampled * Convert depth surface format to a DXGI_FORMAT that can be depth sampled
*/ */
DXGI_FORMAT get_depth_samplable_surface_format(Surface_depth_format format); DXGI_FORMAT get_depth_samplable_surface_format(surface_depth_format format);
/** /**
* Convert front face value to bool value telling wheter front face is counterclockwise or not * Convert front face value to bool value telling wheter front face is counterclockwise or not
@ -96,12 +96,12 @@ BOOL get_front_face_ccw(u32 set_front_face_value);
/** /**
* Convert index type to DXGI_FORMAT * Convert index type to DXGI_FORMAT
*/ */
DXGI_FORMAT get_index_type(Index_array_type index_type); DXGI_FORMAT get_index_type(index_array_type index_type);
/** /**
* Convert vertex attribute format and size to DXGI_FORMAT * Convert vertex attribute format and size to DXGI_FORMAT
*/ */
DXGI_FORMAT get_vertex_attribute_format(Vertex_base_type type, u8 size); DXGI_FORMAT get_vertex_attribute_format(vertex_base_type type, u8 size);
/** /**
* Convert scissor register value to D3D12_RECT * Convert scissor register value to D3D12_RECT

View file

@ -339,17 +339,17 @@ void D3D12GSRender::end()
namespace namespace
{ {
bool is_flip_surface_in_global_memory(Surface_target color_target) bool is_flip_surface_in_global_memory(surface_target color_target)
{ {
switch (color_target) switch (color_target)
{ {
case Surface_target::surface_a: case surface_target::surface_a:
case Surface_target::surface_b: case surface_target::surface_b:
case Surface_target::surfaces_a_b: case surface_target::surfaces_a_b:
case Surface_target::surfaces_a_b_c: case surface_target::surfaces_a_b_c:
case Surface_target::surfaces_a_b_c_d: case surface_target::surfaces_a_b_c_d:
return true; return true;
case Surface_target::none: case surface_target::none:
return false; return false;
} }
throw EXCEPTION("Wrong color_target"); throw EXCEPTION("Wrong color_target");

View file

@ -164,17 +164,17 @@ void D3D12GSRender::load_program()
switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))
{ {
case Surface_target::surface_a: case surface_target::surface_a:
case Surface_target::surface_b: case surface_target::surface_b:
prop.numMRT = 1; prop.numMRT = 1;
break; break;
case Surface_target::surfaces_a_b: case surface_target::surfaces_a_b:
prop.numMRT = 2; prop.numMRT = 2;
break; break;
case Surface_target::surfaces_a_b_c: case surface_target::surfaces_a_b_c:
prop.numMRT = 3; prop.numMRT = 3;
break; break;
case Surface_target::surfaces_a_b_c_d: case surface_target::surfaces_a_b_c_d:
prop.numMRT = 4; prop.numMRT = 4;
break; break;
default: default:
@ -254,12 +254,12 @@ void D3D12GSRender::load_program()
prop.IASet = m_IASet; prop.IASet = m_IASet;
if (!!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE]) if (!!rsx::method_registers[NV4097_SET_RESTART_INDEX_ENABLE])
{ {
Index_array_type index_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type index_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
if (index_type == Index_array_type::unsigned_32b) if (index_type == index_array_type::unsigned_32b)
{ {
prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF; prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF;
} }
if (index_type == Index_array_type::unsigned_16b) if (index_type == index_array_type::unsigned_16b)
{ {
prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF; prop.CutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF;
} }

View file

@ -15,40 +15,40 @@
namespace namespace
{ {
u32 get_max_depth_value(Surface_depth_format format) u32 get_max_depth_value(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return 0xFFFF; case surface_depth_format::z16: return 0xFFFF;
case Surface_depth_format::z24s8: return 0xFFFFFF; case surface_depth_format::z24s8: return 0xFFFFFF;
} }
throw EXCEPTION("Unknow depth format"); throw EXCEPTION("Unknow depth format");
} }
UINT get_num_rtt(Surface_target color_target) UINT get_num_rtt(surface_target color_target)
{ {
switch (color_target) switch (color_target)
{ {
case Surface_target::none: return 0; case surface_target::none: return 0;
case Surface_target::surface_a: case surface_target::surface_a:
case Surface_target::surface_b: return 1; case surface_target::surface_b: return 1;
case Surface_target::surfaces_a_b: return 2; case surface_target::surfaces_a_b: return 2;
case Surface_target::surfaces_a_b_c: return 3; case surface_target::surfaces_a_b_c: return 3;
case Surface_target::surfaces_a_b_c_d: return 4; case surface_target::surfaces_a_b_c_d: return 4;
} }
throw EXCEPTION("Wrong color_target (%d)", color_target); throw EXCEPTION("Wrong color_target (%d)", color_target);
} }
std::vector<u8> get_rtt_indexes(Surface_target color_target) std::vector<u8> get_rtt_indexes(surface_target color_target)
{ {
switch (color_target) switch (color_target)
{ {
case Surface_target::none: return{}; case surface_target::none: return{};
case Surface_target::surface_a: return{ 0 }; case surface_target::surface_a: return{ 0 };
case Surface_target::surface_b: return{ 1 }; case surface_target::surface_b: return{ 1 };
case Surface_target::surfaces_a_b: return{ 0, 1 }; case surface_target::surfaces_a_b: return{ 0, 1 };
case Surface_target::surfaces_a_b_c: return{ 0, 1, 2 }; case surface_target::surfaces_a_b_c: return{ 0, 1, 2 };
case Surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; case surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 };
} }
throw EXCEPTION("Wrong color_target (%d)", color_target); throw EXCEPTION("Wrong color_target (%d)", color_target);
} }
@ -73,46 +73,46 @@ namespace
return register_value & 0xff; return register_value & 0xff;
} }
size_t get_aligned_pitch(Surface_color_format format, u32 width) size_t get_aligned_pitch(surface_color_format format, u32 width)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::b8: return align(width, 256); case surface_color_format::b8: return align(width, 256);
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::r5g6b5: return align(width * 2, 256); case surface_color_format::r5g6b5: return align(width * 2, 256);
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
case Surface_color_format::a8r8g8b8: return align(width * 4, 256); case surface_color_format::a8r8g8b8: return align(width * 4, 256);
case Surface_color_format::w16z16y16x16: return align(width * 8, 256); case surface_color_format::w16z16y16x16: return align(width * 8, 256);
case Surface_color_format::w32z32y32x32: return align(width * 16, 256); case surface_color_format::w32z32y32x32: return align(width * 16, 256);
} }
throw EXCEPTION("Unknow color surface format"); throw EXCEPTION("Unknow color surface format");
} }
size_t get_packed_pitch(Surface_color_format format, u32 width) size_t get_packed_pitch(surface_color_format format, u32 width)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::b8: return width; case surface_color_format::b8: return width;
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::r5g6b5: return width * 2; case surface_color_format::r5g6b5: return width * 2;
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
case Surface_color_format::a8r8g8b8: return width * 4; case surface_color_format::a8r8g8b8: return width * 4;
case Surface_color_format::w16z16y16x16: return width * 8; case surface_color_format::w16z16y16x16: return width * 8;
case Surface_color_format::w32z32y32x32: return width * 16; case surface_color_format::w32z32y32x32: return width * 16;
} }
throw EXCEPTION("Unknow color surface format"); throw EXCEPTION("Unknow color surface format");
} }
@ -242,7 +242,7 @@ namespace
ID3D12GraphicsCommandList * command_list, ID3D12GraphicsCommandList * command_list,
data_heap &readback_heap, data_heap &readback_heap,
ID3D12Resource * color_surface, ID3D12Resource * color_surface,
Surface_color_format color_surface_format surface_color_format color_surface_format
) )
{ {
int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16;

View file

@ -21,10 +21,10 @@ struct render_target_traits
static static
ComPtr<ID3D12Resource> create_new_surface( ComPtr<ID3D12Resource> create_new_surface(
u32 address, u32 address,
Surface_color_format surface_color_format, size_t width, size_t height, surface_color_format color_format, size_t width, size_t height,
gsl::not_null<ID3D12Device*> device, const std::array<float, 4> &clear_color, float, u8) gsl::not_null<ID3D12Device*> device, const std::array<float, 4> &clear_color, float, u8)
{ {
DXGI_FORMAT dxgi_format = get_color_surface_format(surface_color_format); DXGI_FORMAT dxgi_format = get_color_surface_format(color_format);
ComPtr<ID3D12Resource> rtt; ComPtr<ID3D12Resource> rtt;
LOG_WARNING(RSX, "Creating RTT"); LOG_WARNING(RSX, "Creating RTT");
@ -69,7 +69,7 @@ struct render_target_traits
static static
ComPtr<ID3D12Resource> create_new_surface( ComPtr<ID3D12Resource> create_new_surface(
u32 address, u32 address,
Surface_depth_format surfaceDepthFormat, size_t width, size_t height, surface_depth_format surfaceDepthFormat, size_t width, size_t height,
gsl::not_null<ID3D12Device*> device, const std::array<float, 4>& , float clear_depth, u8 clear_stencil) gsl::not_null<ID3D12Device*> device, const std::array<float, 4>& , float clear_depth, u8 clear_stencil)
{ {
D3D12_CLEAR_VALUE clear_depth_value = {}; D3D12_CLEAR_VALUE clear_depth_value = {};
@ -113,14 +113,14 @@ struct render_target_traits
static static
bool rtt_has_format_width_height(const ComPtr<ID3D12Resource> &rtt, Surface_color_format surface_color_format, size_t width, size_t height) bool rtt_has_format_width_height(const ComPtr<ID3D12Resource> &rtt, surface_color_format surface_color_format, size_t width, size_t height)
{ {
DXGI_FORMAT dxgi_format = get_color_surface_format(surface_color_format); DXGI_FORMAT dxgi_format = get_color_surface_format(surface_color_format);
return rtt->GetDesc().Format == dxgi_format && rtt->GetDesc().Width == width && rtt->GetDesc().Height == height; return rtt->GetDesc().Format == dxgi_format && rtt->GetDesc().Width == width && rtt->GetDesc().Height == height;
} }
static static
bool ds_has_format_width_height(const ComPtr<ID3D12Resource> &rtt, Surface_depth_format surface_depth_stencil_format, size_t width, size_t height) bool ds_has_format_width_height(const ComPtr<ID3D12Resource> &rtt, surface_depth_format surface_depth_stencil_format, size_t width, size_t height)
{ {
//TODO: Check format //TODO: Check format
return rtt->GetDesc().Width == width && rtt->GetDesc().Height == height; return rtt->GetDesc().Width == width && rtt->GetDesc().Height == height;
@ -129,7 +129,7 @@ struct render_target_traits
static static
std::tuple<size_t, size_t, size_t, ComPtr<ID3D12Fence>, HANDLE> issue_download_command( std::tuple<size_t, size_t, size_t, ComPtr<ID3D12Fence>, HANDLE> issue_download_command(
gsl::not_null<ID3D12Resource*> rtt, gsl::not_null<ID3D12Resource*> rtt,
Surface_color_format color_format, size_t width, size_t height, surface_color_format color_format, size_t width, size_t height,
gsl::not_null<ID3D12Device*> device, gsl::not_null<ID3D12CommandQueue*> command_queue, data_heap &readback_heap, resource_storage &res_store gsl::not_null<ID3D12Device*> device, gsl::not_null<ID3D12CommandQueue*> command_queue, data_heap &readback_heap, resource_storage &res_store
) )
{ {
@ -162,12 +162,12 @@ struct render_target_traits
static static
std::tuple<size_t, size_t, size_t, ComPtr<ID3D12Fence>, HANDLE> issue_depth_download_command( std::tuple<size_t, size_t, size_t, ComPtr<ID3D12Fence>, HANDLE> issue_depth_download_command(
gsl::not_null<ID3D12Resource*> ds, gsl::not_null<ID3D12Resource*> ds,
Surface_depth_format depth_format, size_t width, size_t height, surface_depth_format depth_format, size_t width, size_t height,
gsl::not_null<ID3D12Device*> device, gsl::not_null<ID3D12CommandQueue*> command_queue, data_heap &readback_heap, resource_storage &res_store gsl::not_null<ID3D12Device*> device, gsl::not_null<ID3D12CommandQueue*> command_queue, data_heap &readback_heap, resource_storage &res_store
) )
{ {
ID3D12GraphicsCommandList* command_list = res_store.command_list.Get(); ID3D12GraphicsCommandList* command_list = res_store.command_list.Get();
DXGI_FORMAT dxgi_format = (depth_format == Surface_depth_format::z24s8) ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_R16_TYPELESS; DXGI_FORMAT dxgi_format = (depth_format == surface_depth_format::z24s8) ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_R16_TYPELESS;
size_t row_pitch = align(width * 4, 256); size_t row_pitch = align(width * 4, 256);
size_t buffer_size = row_pitch * height; size_t buffer_size = row_pitch * height;

View file

@ -719,45 +719,45 @@ namespace
}; };
} }
Vertex_base_type to_vertex_base_type(u8 in) vertex_base_type to_vertex_base_type(u8 in)
{ {
switch (in) switch (in)
{ {
case 1: return Vertex_base_type::s1; case 1: return vertex_base_type::s1;
case 2: return Vertex_base_type::f; case 2: return vertex_base_type::f;
case 3: return Vertex_base_type::sf; case 3: return vertex_base_type::sf;
case 4: return Vertex_base_type::ub; case 4: return vertex_base_type::ub;
case 5: return Vertex_base_type::s32k; case 5: return vertex_base_type::s32k;
case 6: return Vertex_base_type::cmp; case 6: return vertex_base_type::cmp;
case 7: return Vertex_base_type::ub256; case 7: return vertex_base_type::ub256;
} }
throw new EXCEPTION("Unknow vertex base type %d", in); throw new EXCEPTION("Unknow vertex base type %d", in);
} }
Index_array_type to_index_array_type(u8 in) index_array_type to_index_array_type(u8 in)
{ {
switch (in) switch (in)
{ {
case 0: return Index_array_type::unsigned_32b; case 0: return index_array_type::unsigned_32b;
case 1: return Index_array_type::unsigned_16b; case 1: return index_array_type::unsigned_16b;
} }
throw new EXCEPTION("Unknown index array type %d", in); throw new EXCEPTION("Unknown index array type %d", in);
} }
Primitive_type to_primitive_type(u8 in) primitive_type to_primitive_type(u8 in)
{ {
switch (in) switch (in)
{ {
case 1: return Primitive_type::points; case 1: return primitive_type::points;
case 2: return Primitive_type::lines; case 2: return primitive_type::lines;
case 3: return Primitive_type::line_loop; case 3: return primitive_type::line_loop;
case 4: return Primitive_type::line_strip; case 4: return primitive_type::line_strip;
case 5: return Primitive_type::triangles; case 5: return primitive_type::triangles;
case 6: return Primitive_type::triangle_strip; case 6: return primitive_type::triangle_strip;
case 7: return Primitive_type::triangle_fan; case 7: return primitive_type::triangle_fan;
case 8: return Primitive_type::quads; case 8: return primitive_type::quads;
case 9: return Primitive_type::quad_strip; case 9: return primitive_type::quad_strip;
case 10: return Primitive_type::polygon; case 10: return primitive_type::polygon;
} }
throw new EXCEPTION("Unknow primitive type %d", in); throw new EXCEPTION("Unknow primitive type %d", in);
} }
@ -801,26 +801,26 @@ enum
}; };
Surface_target to_surface_target(u8 in) surface_target to_surface_target(u8 in)
{ {
switch (in) switch (in)
{ {
case CELL_GCM_SURFACE_TARGET_NONE: return Surface_target::none; case CELL_GCM_SURFACE_TARGET_NONE: return surface_target::none;
case CELL_GCM_SURFACE_TARGET_0: return Surface_target::surface_a; case CELL_GCM_SURFACE_TARGET_0: return surface_target::surface_a;
case CELL_GCM_SURFACE_TARGET_1: return Surface_target::surface_b; case CELL_GCM_SURFACE_TARGET_1: return surface_target::surface_b;
case CELL_GCM_SURFACE_TARGET_MRT1: return Surface_target::surfaces_a_b; case CELL_GCM_SURFACE_TARGET_MRT1: return surface_target::surfaces_a_b;
case CELL_GCM_SURFACE_TARGET_MRT2: return Surface_target::surfaces_a_b_c; case CELL_GCM_SURFACE_TARGET_MRT2: return surface_target::surfaces_a_b_c;
case CELL_GCM_SURFACE_TARGET_MRT3: return Surface_target::surfaces_a_b_c_d; case CELL_GCM_SURFACE_TARGET_MRT3: return surface_target::surfaces_a_b_c_d;
} }
throw EXCEPTION("Unknow surface target %x", in); throw EXCEPTION("Unknow surface target %x", in);
} }
Surface_depth_format to_surface_depth_format(u8 in) surface_depth_format to_surface_depth_format(u8 in)
{ {
switch (in) switch (in)
{ {
case CELL_GCM_SURFACE_Z16: return Surface_depth_format::z16; case CELL_GCM_SURFACE_Z16: return surface_depth_format::z16;
case CELL_GCM_SURFACE_Z24S8: return Surface_depth_format::z24s8; case CELL_GCM_SURFACE_Z24S8: return surface_depth_format::z24s8;
} }
throw EXCEPTION("Unknow surface depth format %x", in); throw EXCEPTION("Unknow surface depth format %x", in);
} }
@ -836,36 +836,36 @@ std::string rsx::get_method_name(const u32 id)
return fmt::format("unknown/illegal method [0x%08x]", id); return fmt::format("unknown/illegal method [0x%08x]", id);
} }
Surface_antialiasing to_surface_antialiasing(u8 in) surface_antialiasing to_surface_antialiasing(u8 in)
{ {
switch (in) switch (in)
{ {
case CELL_GCM_SURFACE_CENTER_1: return Surface_antialiasing::center_1_sample; case CELL_GCM_SURFACE_CENTER_1: return surface_antialiasing::center_1_sample;
case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return Surface_antialiasing::diagonal_centered_2_samples; case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return surface_antialiasing::diagonal_centered_2_samples;
case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return Surface_antialiasing::square_centered_4_samples; case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return surface_antialiasing::square_centered_4_samples;
case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return Surface_antialiasing::square_rotated_4_samples; case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return surface_antialiasing::square_rotated_4_samples;
} }
throw EXCEPTION("unknow surface antialiasing format %x", in); throw EXCEPTION("unknow surface antialiasing format %x", in);
} }
Surface_color_format to_surface_color_format(u8 in) surface_color_format to_surface_color_format(u8 in)
{ {
switch (in) switch (in)
{ {
case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return Surface_color_format::x1r5g5b5_z1r5g5b5; case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return surface_color_format::x1r5g5b5_z1r5g5b5;
case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return Surface_color_format::x1r5g5b5_o1r5g5b5; case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return surface_color_format::x1r5g5b5_o1r5g5b5;
case CELL_GCM_SURFACE_R5G6B5: return Surface_color_format::r5g6b5; case CELL_GCM_SURFACE_R5G6B5: return surface_color_format::r5g6b5;
case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return Surface_color_format::x8r8g8b8_z8r8g8b8; case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return surface_color_format::x8r8g8b8_z8r8g8b8;
case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return Surface_color_format::x8r8g8b8_o8r8g8b8; case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return surface_color_format::x8r8g8b8_o8r8g8b8;
case CELL_GCM_SURFACE_A8R8G8B8: return Surface_color_format::a8r8g8b8; case CELL_GCM_SURFACE_A8R8G8B8: return surface_color_format::a8r8g8b8;
case CELL_GCM_SURFACE_B8: return Surface_color_format::b8; case CELL_GCM_SURFACE_B8: return surface_color_format::b8;
case CELL_GCM_SURFACE_G8B8: return Surface_color_format::g8b8; case CELL_GCM_SURFACE_G8B8: return surface_color_format::g8b8;
case CELL_GCM_SURFACE_F_W16Z16Y16X16: return Surface_color_format::w16z16y16x16; case CELL_GCM_SURFACE_F_W16Z16Y16X16: return surface_color_format::w16z16y16x16;
case CELL_GCM_SURFACE_F_W32Z32Y32X32: return Surface_color_format::w32z32y32x32; case CELL_GCM_SURFACE_F_W32Z32Y32X32: return surface_color_format::w32z32y32x32;
case CELL_GCM_SURFACE_F_X32: return Surface_color_format::x32; case CELL_GCM_SURFACE_F_X32: return surface_color_format::x32;
case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return Surface_color_format::x8b8g8r8_z8b8g8r8; case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return surface_color_format::x8b8g8r8_z8b8g8r8;
case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return Surface_color_format::x8b8g8r8_o8b8g8r8; case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return surface_color_format::x8b8g8r8_o8b8g8r8;
case CELL_GCM_SURFACE_A8B8G8R8: return Surface_color_format::a8b8g8r8; case CELL_GCM_SURFACE_A8B8G8R8: return surface_color_format::a8b8g8r8;
} }
throw EXCEPTION("unknow surface color format %x", in); throw EXCEPTION("unknow surface color format %x", in);
} }
@ -955,16 +955,16 @@ namespace
{ {
switch (to_primitive_type(draw_mode)) switch (to_primitive_type(draw_mode))
{ {
case Primitive_type::points: return "Points"; case primitive_type::points: return "Points";
case Primitive_type::lines: return "Lines"; case primitive_type::lines: return "Lines";
case Primitive_type::line_loop: return "Line_loop"; case primitive_type::line_loop: return "Line_loop";
case Primitive_type::line_strip: return "Line_strip"; case primitive_type::line_strip: return "Line_strip";
case Primitive_type::triangles: return "Triangles"; case primitive_type::triangles: return "Triangles";
case Primitive_type::triangle_strip: return "Triangle_strip"; case primitive_type::triangle_strip: return "Triangle_strip";
case Primitive_type::triangle_fan: return "Triangle_fan"; case primitive_type::triangle_fan: return "Triangle_fan";
case Primitive_type::quads: return "Quads"; case primitive_type::quads: return "Quads";
case Primitive_type::quad_strip: return "Quad_strip"; case primitive_type::quad_strip: return "Quad_strip";
case Primitive_type::polygon: return "Polygon"; case primitive_type::polygon: return "Polygon";
} }
return "Error"; return "Error";
} }
@ -991,8 +991,8 @@ namespace
{ {
switch (to_surface_depth_format(format)) switch (to_surface_depth_format(format))
{ {
case Surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16"; case surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16";
case Surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8"; case surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8";
} }
return "Error"; return "Error";
} }
@ -1001,10 +1001,10 @@ namespace
{ {
switch (to_surface_antialiasing(format)) switch (to_surface_antialiasing(format))
{ {
case Surface_antialiasing::center_1_sample: "1 sample centered"; case surface_antialiasing::center_1_sample: "1 sample centered";
case Surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered"; case surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered";
case Surface_antialiasing::square_centered_4_samples: return "4 samples square centered"; case surface_antialiasing::square_centered_4_samples: return "4 samples square centered";
case Surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated"; case surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated";
} }
return "Error"; return "Error";
} }
@ -1013,20 +1013,20 @@ namespace
{ {
switch (to_surface_color_format(format)) switch (to_surface_color_format(format))
{ {
case Surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5"; case surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5";
case Surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5"; case surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5";
case Surface_color_format::r5g6b5 : return "CELL_GCM_SURFACE_R5G6B5"; case surface_color_format::r5g6b5 : return "CELL_GCM_SURFACE_R5G6B5";
case Surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8"; case surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8";
case Surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8"; case surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8";
case Surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8"; case surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8";
case Surface_color_format::b8: return "CELL_GCM_SURFACE_B8"; case surface_color_format::b8: return "CELL_GCM_SURFACE_B8";
case Surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8"; case surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8";
case Surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16"; case surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16";
case Surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32"; case surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32";
case Surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32"; case surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32";
case Surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8"; case surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8";
case Surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8"; case surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8";
case Surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8"; case surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8";
} }
return "Error"; return "Error";
} }
@ -1035,12 +1035,12 @@ namespace
{ {
switch (to_surface_target(target)) switch (to_surface_target(target))
{ {
case Surface_target::none: return "none"; case surface_target::none: return "none";
case Surface_target::surface_a: return "surface A"; case surface_target::surface_a: return "surface A";
case Surface_target::surface_b: return "surface B"; case surface_target::surface_b: return "surface B";
case Surface_target::surfaces_a_b: return "surfaces A and B"; case surface_target::surfaces_a_b: return "surfaces A and B";
case Surface_target::surfaces_a_b_c: return "surfaces A, B and C"; case surface_target::surfaces_a_b_c: return "surfaces A, B and C";
case Surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D"; case surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D";
} }
return "Error"; return "Error";
} }
@ -1080,13 +1080,13 @@ namespace
{ {
switch (to_vertex_base_type(type)) switch (to_vertex_base_type(type))
{ {
case Vertex_base_type::s1: return "Short"; case vertex_base_type::s1: return "Short";
case Vertex_base_type::f: return "Float"; case vertex_base_type::f: return "Float";
case Vertex_base_type::sf: return "Half float"; case vertex_base_type::sf: return "Half float";
case Vertex_base_type::ub: return "Unsigned byte"; case vertex_base_type::ub: return "Unsigned byte";
case Vertex_base_type::s32k: return "Signed int"; case vertex_base_type::s32k: return "Signed int";
case Vertex_base_type::cmp: return "CMP"; case vertex_base_type::cmp: return "CMP";
case Vertex_base_type::ub256: return "UB256"; case vertex_base_type::ub256: return "UB256";
} }
} }
@ -1106,8 +1106,8 @@ namespace
{ {
switch (to_index_array_type(arg)) switch (to_index_array_type(arg))
{ {
case Index_array_type::unsigned_16b: return "unsigned short"; case index_array_type::unsigned_16b: return "unsigned short";
case Index_array_type::unsigned_32b: return "unsigned int"; case index_array_type::unsigned_32b: return "unsigned int";
} }
return "Error"; return "Error";
} }

View file

@ -23,7 +23,7 @@ enum
CELL_GCM_DISPLAY_FREQUENCY_DISABLE = 3, CELL_GCM_DISPLAY_FREQUENCY_DISABLE = 3,
}; };
enum class Vertex_base_type : u8 enum class vertex_base_type : u8
{ {
s1, ///< signed byte s1, ///< signed byte
f, ///< float f, ///< float
@ -34,17 +34,17 @@ enum class Vertex_base_type : u8
ub256, ub256,
}; };
Vertex_base_type to_vertex_base_type(u8 in); vertex_base_type to_vertex_base_type(u8 in);
enum class Index_array_type : u8 enum class index_array_type : u8
{ {
unsigned_32b, unsigned_32b,
unsigned_16b, unsigned_16b,
}; };
Index_array_type to_index_array_type(u8 in); index_array_type to_index_array_type(u8 in);
enum class Primitive_type : u8 enum class primitive_type : u8
{ {
points, points,
lines, lines,
@ -58,9 +58,9 @@ enum class Primitive_type : u8
polygon, // convex polygon polygon, // convex polygon
}; };
Primitive_type to_primitive_type(u8 in); primitive_type to_primitive_type(u8 in);
enum class Surface_target : u8 enum class surface_target : u8
{ {
none, none,
surface_a, surface_a,
@ -70,17 +70,17 @@ enum class Surface_target : u8
surfaces_a_b_c_d, surfaces_a_b_c_d,
}; };
Surface_target to_surface_target(u8 in); surface_target to_surface_target(u8 in);
enum class Surface_depth_format : u8 enum class surface_depth_format : u8
{ {
z16, // unsigned 16 bits depth z16, // unsigned 16 bits depth
z24s8, // unsigned 24 bits depth + 8 bits stencil z24s8, // unsigned 24 bits depth + 8 bits stencil
}; };
Surface_depth_format to_surface_depth_format(u8 in); surface_depth_format to_surface_depth_format(u8 in);
enum class Surface_antialiasing : u8 enum class surface_antialiasing : u8
{ {
center_1_sample, center_1_sample,
diagonal_centered_2_samples, diagonal_centered_2_samples,
@ -88,9 +88,9 @@ enum class Surface_antialiasing : u8
square_rotated_4_samples, square_rotated_4_samples,
}; };
Surface_antialiasing to_surface_antialiasing(u8 in); surface_antialiasing to_surface_antialiasing(u8 in);
enum class Surface_color_format : u8 enum class surface_color_format : u8
{ {
x1r5g5b5_z1r5g5b5, x1r5g5b5_z1r5g5b5,
x1r5g5b5_o1r5g5b5, x1r5g5b5_o1r5g5b5,
@ -108,7 +108,7 @@ enum class Surface_color_format : u8
a8b8g8r8, a8b8g8r8,
}; };
Surface_color_format to_surface_color_format(u8 in); surface_color_format to_surface_color_format(u8 in);
enum enum
{ {

View file

@ -11,22 +11,22 @@
namespace namespace
{ {
u32 get_max_depth_value(Surface_depth_format format) u32 get_max_depth_value(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return 0xFFFF; case surface_depth_format::z16: return 0xFFFF;
case Surface_depth_format::z24s8: return 0xFFFFFF; case surface_depth_format::z24s8: return 0xFFFFFF;
} }
throw EXCEPTION("Unknow depth format"); throw EXCEPTION("Unknow depth format");
} }
u8 get_pixel_size(Surface_depth_format format) u8 get_pixel_size(surface_depth_format format)
{ {
switch (format) switch (format)
{ {
case Surface_depth_format::z16: return 2; case surface_depth_format::z16: return 2;
case Surface_depth_format::z24s8: return 4; case surface_depth_format::z24s8: return 4;
} }
throw EXCEPTION("Unknow depth format"); throw EXCEPTION("Unknow depth format");
} }
@ -120,7 +120,7 @@ void GLGSRender::begin()
__glcheck glBlendFuncSeparate(sfactor_rgb, dfactor_rgb, sfactor_a, dfactor_a); __glcheck glBlendFuncSeparate(sfactor_rgb, dfactor_rgb, sfactor_a, dfactor_a);
if (m_surface.color_format == Surface_color_format::w16z16y16x16) //TODO: check another color formats if (m_surface.color_format == surface_color_format::w16z16y16x16) //TODO: check another color formats
{ {
u32 blend_color = rsx::method_registers[NV4097_SET_BLEND_COLOR]; u32 blend_color = rsx::method_registers[NV4097_SET_BLEND_COLOR];
u32 blend_color2 = rsx::method_registers[NV4097_SET_BLEND_COLOR2]; u32 blend_color2 = rsx::method_registers[NV4097_SET_BLEND_COLOR2];
@ -318,33 +318,33 @@ void apply_attrib_array(gl::glsl::program& program, int location, const std::vec
namespace namespace
{ {
gl::buffer_pointer::type gl_types(Vertex_base_type type) gl::buffer_pointer::type gl_types(vertex_base_type type)
{ {
switch (type) switch (type)
{ {
case Vertex_base_type::s1: return gl::buffer_pointer::type::s16; case vertex_base_type::s1: return gl::buffer_pointer::type::s16;
case Vertex_base_type::f: return gl::buffer_pointer::type::f32; case vertex_base_type::f: return gl::buffer_pointer::type::f32;
case Vertex_base_type::sf: return gl::buffer_pointer::type::f16; case vertex_base_type::sf: return gl::buffer_pointer::type::f16;
case Vertex_base_type::ub: return gl::buffer_pointer::type::u8; case vertex_base_type::ub: return gl::buffer_pointer::type::u8;
case Vertex_base_type::s32k: return gl::buffer_pointer::type::s32; case vertex_base_type::s32k: return gl::buffer_pointer::type::s32;
case Vertex_base_type::cmp: return gl::buffer_pointer::type::s16; // Needs conversion case vertex_base_type::cmp: return gl::buffer_pointer::type::s16; // Needs conversion
case Vertex_base_type::ub256: gl::buffer_pointer::type::u8; case vertex_base_type::ub256: gl::buffer_pointer::type::u8;
} }
throw EXCEPTION("unknow vertex type"); throw EXCEPTION("unknow vertex type");
} }
bool gl_normalized(Vertex_base_type type) bool gl_normalized(vertex_base_type type)
{ {
switch (type) switch (type)
{ {
case Vertex_base_type::s1: case vertex_base_type::s1:
case Vertex_base_type::ub: case vertex_base_type::ub:
case Vertex_base_type::cmp: case vertex_base_type::cmp:
return true; return true;
case Vertex_base_type::f: case vertex_base_type::f:
case Vertex_base_type::sf: case vertex_base_type::sf:
case Vertex_base_type::ub256: case vertex_base_type::ub256:
case Vertex_base_type::s32k: case vertex_base_type::s32k:
return false; return false;
} }
throw EXCEPTION("unknow vertex type"); throw EXCEPTION("unknow vertex type");
@ -402,9 +402,9 @@ void GLGSRender::end()
std::vector<u8> vertex_index_array; std::vector<u8> vertex_index_array;
vertex_draw_count = 0; vertex_draw_count = 0;
u32 min_index, max_index; u32 min_index, max_index;
if (draw_command == Draw_command::draw_command_indexed) if (draw_command == rsx::draw_command::indexed)
{ {
Index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
u32 type_size = gsl::narrow<u32>(get_index_type_size(type)); u32 type_size = gsl::narrow<u32>(get_index_type_size(type));
for (const auto& first_count : first_count_commands) for (const auto& first_count : first_count_commands)
{ {
@ -415,16 +415,16 @@ void GLGSRender::end()
switch (type) switch (type)
{ {
case Index_array_type::unsigned_32b: case index_array_type::unsigned_32b:
std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span<u32>((u32*)vertex_index_array.data(), vertex_draw_count), first_count_commands); std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span<u32>((u32*)vertex_index_array.data(), vertex_draw_count), first_count_commands);
break; break;
case Index_array_type::unsigned_16b: case index_array_type::unsigned_16b:
std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span<u16>((u16*)vertex_index_array.data(), vertex_draw_count), first_count_commands); std::tie(min_index, max_index) = write_index_array_data_to_buffer_untouched(gsl::span<u16>((u16*)vertex_index_array.data(), vertex_draw_count), first_count_commands);
break; break;
} }
} }
if (draw_command == Draw_command::draw_command_inlined_array) if (draw_command == rsx::draw_command::inlined_array)
{ {
write_inline_array_to_buffer(vertex_arrays_data.data()); write_inline_array_to_buffer(vertex_arrays_data.data());
u32 offset = 0; u32 offset = 0;
@ -446,7 +446,7 @@ void GLGSRender::end()
} }
} }
if (draw_command == Draw_command::draw_command_array) if (draw_command == rsx::draw_command::array)
{ {
for (const auto &first_count : first_count_commands) for (const auto &first_count : first_count_commands)
{ {
@ -454,7 +454,7 @@ void GLGSRender::end()
} }
} }
if (draw_command == Draw_command::draw_command_array || draw_command == Draw_command::draw_command_indexed) if (draw_command == rsx::draw_command::array || draw_command == rsx::draw_command::indexed)
{ {
for (int index = 0; index < rsx::limits::vertex_count; ++index) for (int index = 0; index < rsx::limits::vertex_count; ++index)
{ {
@ -475,7 +475,7 @@ void GLGSRender::end()
// Fill vertex_array // Fill vertex_array
u32 element_size = rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.size); u32 element_size = rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.size);
vertex_array.resize(vertex_draw_count * element_size); vertex_array.resize(vertex_draw_count * element_size);
if (draw_command == Draw_command::draw_command_array) if (draw_command == rsx::draw_command::array)
{ {
size_t offset = 0; size_t offset = 0;
for (const auto &first_count : first_count_commands) for (const auto &first_count : first_count_commands)
@ -484,7 +484,7 @@ void GLGSRender::end()
offset += first_count.second * element_size; offset += first_count.second * element_size;
} }
} }
if (draw_command == Draw_command::draw_command_indexed) if (draw_command == rsx::draw_command::indexed)
{ {
vertex_array.resize((max_index + 1) * element_size); vertex_array.resize((max_index + 1) * element_size);
write_vertex_array_data_to_buffer(vertex_array.data(), 0, max_index + 1, index, vertex_info); write_vertex_array_data_to_buffer(vertex_array.data(), 0, max_index + 1, index, vertex_info);
@ -508,7 +508,7 @@ void GLGSRender::end()
switch (vertex_info.type) switch (vertex_info.type)
{ {
case Vertex_base_type::f: case vertex_base_type::f:
switch (register_vertex_info[index].size) switch (register_vertex_info[index].size)
{ {
case 1: apply_attrib_array<f32, 1>(*m_program, location, vertex_data); break; case 1: apply_attrib_array<f32, 1>(*m_program, location, vertex_data); break;
@ -527,15 +527,15 @@ void GLGSRender::end()
} }
m_vbo.data(vertex_arrays_data.size(), vertex_arrays_data.data()); m_vbo.data(vertex_arrays_data.size(), vertex_arrays_data.data());
if (draw_command == Draw_command::draw_command_indexed) if (draw_command == rsx::draw_command::indexed)
{ {
m_ebo.data(vertex_index_array.size(), vertex_index_array.data()); m_ebo.data(vertex_index_array.size(), vertex_index_array.data());
Index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4); index_array_type indexed_type = to_index_array_type(rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4);
if (indexed_type == Index_array_type::unsigned_32b) if (indexed_type == index_array_type::unsigned_32b)
__glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_INT, nullptr); __glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_INT, nullptr);
if (indexed_type == Index_array_type::unsigned_16b) if (indexed_type == index_array_type::unsigned_16b)
__glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_SHORT, nullptr); __glcheck glDrawElements(gl::draw_mode(draw_mode), vertex_draw_count, GL_UNSIGNED_SHORT, nullptr);
} }
else else
@ -677,7 +677,7 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer)
if (arg & 0x1) if (arg & 0x1)
{ {
Surface_depth_format surface_depth_format = to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7); surface_depth_format surface_depth_format = to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7);
u32 max_depth_value = get_max_depth_value(surface_depth_format); u32 max_depth_value = get_max_depth_value(surface_depth_format);
u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8; u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8;
@ -855,52 +855,52 @@ struct color_format
color_swizzle swizzle; color_swizzle swizzle;
}; };
color_format surface_color_format_to_gl(Surface_color_format color_format) color_format surface_color_format_to_gl(surface_color_format color_format)
{ {
//color format //color format
switch (color_format) switch (color_format)
{ {
case Surface_color_format::r5g6b5: case surface_color_format::r5g6b5:
return{ gl::texture::type::ushort_5_6_5, gl::texture::format::bgr, false, 3, 2 }; return{ gl::texture::type::ushort_5_6_5, gl::texture::format::bgr, false, 3, 2 };
case Surface_color_format::a8r8g8b8: case surface_color_format::a8r8g8b8:
return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 }; return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 };
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1, return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1,
{ gl::texture::channel::one, gl::texture::channel::r, gl::texture::channel::g, gl::texture::channel::b } }; { gl::texture::channel::one, gl::texture::channel::r, gl::texture::channel::g, gl::texture::channel::b } };
case Surface_color_format::w16z16y16x16: case surface_color_format::w16z16y16x16:
return{ gl::texture::type::f16, gl::texture::format::rgba, true, 4, 2 }; return{ gl::texture::type::f16, gl::texture::format::rgba, true, 4, 2 };
case Surface_color_format::w32z32y32x32: case surface_color_format::w32z32y32x32:
return{ gl::texture::type::f32, gl::texture::format::rgba, true, 4, 4 }; return{ gl::texture::type::f32, gl::texture::format::rgba, true, 4, 4 };
case Surface_color_format::b8: case surface_color_format::b8:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::x32: case surface_color_format::x32:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
default: default:
LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", color_format); LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", color_format);
return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 }; return{ gl::texture::type::uint_8_8_8_8, gl::texture::format::bgra, false, 4, 1 };
} }
} }
std::pair<gl::texture::type, gl::texture::format> surface_depth_format_to_gl(Surface_depth_format depth_format) std::pair<gl::texture::type, gl::texture::format> surface_depth_format_to_gl(surface_depth_format depth_format)
{ {
switch (depth_format) switch (depth_format)
{ {
case Surface_depth_format::z16: case surface_depth_format::z16:
return std::make_pair(gl::texture::type::ushort, gl::texture::format::depth); return std::make_pair(gl::texture::type::ushort, gl::texture::format::depth);
default: default:
LOG_ERROR(RSX, "Surface depth buffer: Unsupported surface depth format (0x%x)", depth_format); LOG_ERROR(RSX, "Surface depth buffer: Unsupported surface depth format (0x%x)", depth_format);
case Surface_depth_format::z24s8: case surface_depth_format::z24s8:
return std::make_pair(gl::texture::type::uint_24_8, gl::texture::format::depth_stencil); return std::make_pair(gl::texture::type::uint_24_8, gl::texture::format::depth_stencil);
//return std::make_pair(gl::texture::type::f32, gl::texture::format::depth); //return std::make_pair(gl::texture::type::f32, gl::texture::format::depth);
} }
@ -949,7 +949,7 @@ void GLGSRender::init_buffers(bool skip_reading)
switch (m_surface.depth_format) switch (m_surface.depth_format)
{ {
case Surface_depth_format::z16: case surface_depth_format::z16:
{ {
__glcheck m_draw_tex_depth_stencil.config() __glcheck m_draw_tex_depth_stencil.config()
.size({ (int)m_surface.width, (int)m_surface.height }) .size({ (int)m_surface.width, (int)m_surface.height })
@ -961,7 +961,7 @@ void GLGSRender::init_buffers(bool skip_reading)
break; break;
} }
case Surface_depth_format::z24s8: case surface_depth_format::z24s8:
{ {
__glcheck m_draw_tex_depth_stencil.config() __glcheck m_draw_tex_depth_stencil.config()
.size({ (int)m_surface.width, (int)m_surface.height }) .size({ (int)m_surface.width, (int)m_surface.height })
@ -994,25 +994,25 @@ void GLGSRender::init_buffers(bool skip_reading)
switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))
{ {
case Surface_target::none: break; case surface_target::none: break;
case Surface_target::surface_a: case surface_target::surface_a:
__glcheck draw_fbo.draw_buffer(draw_fbo.color[0]); __glcheck draw_fbo.draw_buffer(draw_fbo.color[0]);
break; break;
case Surface_target::surface_b: case surface_target::surface_b:
__glcheck draw_fbo.draw_buffer(draw_fbo.color[1] ); __glcheck draw_fbo.draw_buffer(draw_fbo.color[1] );
break; break;
case Surface_target::surfaces_a_b: case surface_target::surfaces_a_b:
__glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1] }); __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1] });
break; break;
case Surface_target::surfaces_a_b_c: case surface_target::surfaces_a_b_c:
__glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2] }); __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2] });
break; break;
case Surface_target::surfaces_a_b_c_d: case surface_target::surfaces_a_b_c_d:
__glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2], draw_fbo.color[3] }); __glcheck draw_fbo.draw_buffers({ draw_fbo.color[0], draw_fbo.color[1], draw_fbo.color[2], draw_fbo.color[3] });
break; break;
@ -1092,26 +1092,26 @@ void GLGSRender::read_buffers()
switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))
{ {
case Surface_target::none: case surface_target::none:
break; break;
case Surface_target::surface_a: case surface_target::surface_a:
read_color_buffers(0, 1); read_color_buffers(0, 1);
break; break;
case Surface_target::surface_b: case surface_target::surface_b:
read_color_buffers(1, 1); read_color_buffers(1, 1);
break; break;
case Surface_target::surfaces_a_b: case surface_target::surfaces_a_b:
read_color_buffers(0, 2); read_color_buffers(0, 2);
break; break;
case Surface_target::surfaces_a_b_c: case surface_target::surfaces_a_b_c:
read_color_buffers(0, 3); read_color_buffers(0, 3);
break; break;
case Surface_target::surfaces_a_b_c_d: case surface_target::surfaces_a_b_c_d:
read_color_buffers(0, 4); read_color_buffers(0, 4);
break; break;
} }
@ -1135,7 +1135,7 @@ void GLGSRender::read_buffers()
{ {
u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]); u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]);
if (m_surface.depth_format == Surface_depth_format::z16) if (m_surface.depth_format == surface_depth_format::z16)
{ {
u16 *dst = (u16*)pixels; u16 *dst = (u16*)pixels;
const be_t<u16>* src = vm::ps3::_ptr<u16>(depth_address); const be_t<u16>* src = vm::ps3::_ptr<u16>(depth_address);
@ -1223,26 +1223,26 @@ void GLGSRender::write_buffers()
switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) switch (to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]))
{ {
case Surface_target::none: case surface_target::none:
break; break;
case Surface_target::surface_a: case surface_target::surface_a:
write_color_buffers(0, 1); write_color_buffers(0, 1);
break; break;
case Surface_target::surface_b: case surface_target::surface_b:
write_color_buffers(1, 1); write_color_buffers(1, 1);
break; break;
case Surface_target::surfaces_a_b: case surface_target::surfaces_a_b:
write_color_buffers(0, 2); write_color_buffers(0, 2);
break; break;
case Surface_target::surfaces_a_b_c: case surface_target::surfaces_a_b_c:
write_color_buffers(0, 3); write_color_buffers(0, 3);
break; break;
case Surface_target::surfaces_a_b_c_d: case surface_target::surfaces_a_b_c_d:
write_color_buffers(0, 4); write_color_buffers(0, 4);
break; break;
} }
@ -1269,7 +1269,7 @@ void GLGSRender::write_buffers()
{ {
u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]); u32 depth_address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]);
if (m_surface.depth_format == Surface_depth_format::z16) if (m_surface.depth_format == surface_depth_format::z16)
{ {
const u16 *src = (const u16*)pixels; const u16 *src = (const u16*)pixels;
be_t<u16>* dst = vm::ps3::_ptr<u16>(depth_address); be_t<u16>* dst = vm::ps3::_ptr<u16>(depth_address);

View file

@ -5,20 +5,20 @@ namespace gl
{ {
const fbo screen{}; const fbo screen{};
GLenum draw_mode(Primitive_type in) GLenum draw_mode(primitive_type in)
{ {
switch (in) switch (in)
{ {
case Primitive_type::points: return GL_POINTS; case primitive_type::points: return GL_POINTS;
case Primitive_type::lines: return GL_LINES; case primitive_type::lines: return GL_LINES;
case Primitive_type::line_loop: return GL_LINE_LOOP; case primitive_type::line_loop: return GL_LINE_LOOP;
case Primitive_type::line_strip: return GL_LINE_STRIP; case primitive_type::line_strip: return GL_LINE_STRIP;
case Primitive_type::triangles: return GL_TRIANGLES; case primitive_type::triangles: return GL_TRIANGLES;
case Primitive_type::triangle_strip: return GL_TRIANGLE_STRIP; case primitive_type::triangle_strip: return GL_TRIANGLE_STRIP;
case Primitive_type::triangle_fan: return GL_TRIANGLE_FAN; case primitive_type::triangle_fan: return GL_TRIANGLE_FAN;
case Primitive_type::quads: return GL_QUADS; case primitive_type::quads: return GL_QUADS;
case Primitive_type::quad_strip: return GL_QUAD_STRIP; case primitive_type::quad_strip: return GL_QUAD_STRIP;
case Primitive_type::polygon: return GL_POLYGON; case primitive_type::polygon: return GL_POLYGON;
} }
throw new EXCEPTION("unknow primitive type"); throw new EXCEPTION("unknow primitive type");
} }
@ -97,74 +97,74 @@ namespace gl
__glcheck glDrawBuffers((GLsizei)ids.size(), ids.data()); __glcheck glDrawBuffers((GLsizei)ids.size(), ids.data());
} }
void fbo::draw_arrays(Primitive_type mode, GLsizei count, GLint first) const void fbo::draw_arrays(primitive_type mode, GLsizei count, GLint first) const
{ {
save_binding_state save(*this); save_binding_state save(*this);
__glcheck glDrawArrays(draw_mode(mode), first, count); __glcheck glDrawArrays(draw_mode(mode), first, count);
} }
void fbo::draw_arrays(const buffer& buffer, Primitive_type mode, GLsizei count, GLint first) const void fbo::draw_arrays(const buffer& buffer, primitive_type mode, GLsizei count, GLint first) const
{ {
buffer.bind(buffer::target::array); buffer.bind(buffer::target::array);
draw_arrays(mode, count, first); draw_arrays(mode, count, first);
} }
void fbo::draw_arrays(const vao& buffer, Primitive_type mode, GLsizei count, GLint first) const void fbo::draw_arrays(const vao& buffer, primitive_type mode, GLsizei count, GLint first) const
{ {
buffer.bind(); buffer.bind();
draw_arrays(mode, count, first); draw_arrays(mode, count, first);
} }
void fbo::draw_elements(Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const void fbo::draw_elements(primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const
{ {
save_binding_state save(*this); save_binding_state save(*this);
__glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices);
} }
void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const
{ {
buffer.bind(buffer::target::array); buffer.bind(buffer::target::array);
__glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, indices);
} }
void fbo::draw_elements(Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const void fbo::draw_elements(primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const
{ {
indices.bind(buffer::target::element_array); indices.bind(buffer::target::element_array);
__glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, (GLvoid*)indices_buffer_offset); __glcheck glDrawElements(draw_mode(mode), count, (GLenum)type, (GLvoid*)indices_buffer_offset);
} }
void fbo::draw_elements(const buffer& buffer_, Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const void fbo::draw_elements(const buffer& buffer_, primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const
{ {
buffer_.bind(buffer::target::array); buffer_.bind(buffer::target::array);
draw_elements(mode, count, type, indices, indices_buffer_offset); draw_elements(mode, count, type, indices, indices_buffer_offset);
} }
void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLubyte *indices) const void fbo::draw_elements(primitive_type mode, GLsizei count, const GLubyte *indices) const
{ {
draw_elements(mode, count, indices_type::ubyte, indices); draw_elements(mode, count, indices_type::ubyte, indices);
} }
void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLubyte *indices) const void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLubyte *indices) const
{ {
draw_elements(buffer, mode, count, indices_type::ubyte, indices); draw_elements(buffer, mode, count, indices_type::ubyte, indices);
} }
void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLushort *indices) const void fbo::draw_elements(primitive_type mode, GLsizei count, const GLushort *indices) const
{ {
draw_elements(mode, count, indices_type::ushort, indices); draw_elements(mode, count, indices_type::ushort, indices);
} }
void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLushort *indices) const void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLushort *indices) const
{ {
draw_elements(buffer, mode, count, indices_type::ushort, indices); draw_elements(buffer, mode, count, indices_type::ushort, indices);
} }
void fbo::draw_elements(Primitive_type mode, GLsizei count, const GLuint *indices) const void fbo::draw_elements(primitive_type mode, GLsizei count, const GLuint *indices) const
{ {
draw_elements(mode, count, indices_type::uint, indices); draw_elements(mode, count, indices_type::uint, indices);
} }
void fbo::draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLuint *indices) const void fbo::draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLuint *indices) const
{ {
draw_elements(buffer, mode, count, indices_type::uint, indices); draw_elements(buffer, mode, count, indices_type::uint, indices);
} }

View file

@ -1380,7 +1380,7 @@ namespace gl
settings& border_color(color4f value); settings& border_color(color4f value);
}; };
GLenum draw_mode(Primitive_type in); GLenum draw_mode(primitive_type in);
enum class indices_type enum class indices_type
{ {
@ -1523,20 +1523,20 @@ namespace gl
void draw_buffer(const attachment& buffer) const; void draw_buffer(const attachment& buffer) const;
void draw_buffers(const std::initializer_list<attachment>& indexes) const; void draw_buffers(const std::initializer_list<attachment>& indexes) const;
void draw_arrays(Primitive_type mode, GLsizei count, GLint first = 0) const; void draw_arrays(primitive_type mode, GLsizei count, GLint first = 0) const;
void draw_arrays(const buffer& buffer, Primitive_type mode, GLsizei count, GLint first = 0) const; void draw_arrays(const buffer& buffer, primitive_type mode, GLsizei count, GLint first = 0) const;
void draw_arrays(const vao& buffer, Primitive_type mode, GLsizei count, GLint first = 0) const; void draw_arrays(const vao& buffer, primitive_type mode, GLsizei count, GLint first = 0) const;
void draw_elements(Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; void draw_elements(primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const;
void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const;
void draw_elements(Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; void draw_elements(primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const;
void draw_elements(const buffer& buffer_, Primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; void draw_elements(const buffer& buffer_, primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const;
void draw_elements(Primitive_type mode, GLsizei count, const GLubyte *indices) const; void draw_elements(primitive_type mode, GLsizei count, const GLubyte *indices) const;
void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLubyte *indices) const; void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLubyte *indices) const;
void draw_elements(Primitive_type mode, GLsizei count, const GLushort *indices) const; void draw_elements(primitive_type mode, GLsizei count, const GLushort *indices) const;
void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLushort *indices) const; void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLushort *indices) const;
void draw_elements(Primitive_type mode, GLsizei count, const GLuint *indices) const; void draw_elements(primitive_type mode, GLsizei count, const GLuint *indices) const;
void draw_elements(const buffer& buffer, Primitive_type mode, GLsizei count, const GLuint *indices) const; void draw_elements(const buffer& buffer, primitive_type mode, GLsizei count, const GLuint *indices) const;
void clear(buffers buffers_) const; void clear(buffers buffers_) const;
void clear(buffers buffers_, color4f color_value, double depth_value, u8 stencil_value) const; void clear(buffers buffers_, color4f color_value, double depth_value, u8 stencil_value) const;

View file

@ -122,11 +122,11 @@ namespace rsx
return res; return res;
} }
u32 get_vertex_type_size_on_host(Vertex_base_type type, u32 size) u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size)
{ {
switch (type) switch (type)
{ {
case Vertex_base_type::s1: case vertex_base_type::s1:
switch (size) switch (size)
{ {
case 1: case 1:
@ -137,8 +137,8 @@ namespace rsx
return sizeof(u16) * 4; return sizeof(u16) * 4;
} }
throw new EXCEPTION("Wrong vector size"); throw new EXCEPTION("Wrong vector size");
case Vertex_base_type::f: return sizeof(f32) * size; case vertex_base_type::f: return sizeof(f32) * size;
case Vertex_base_type::sf: case vertex_base_type::sf:
switch (size) switch (size)
{ {
case 1: case 1:
@ -149,7 +149,7 @@ namespace rsx
return sizeof(f16) * 4; return sizeof(f16) * 4;
} }
throw new EXCEPTION("Wrong vector size"); throw new EXCEPTION("Wrong vector size");
case Vertex_base_type::ub: case vertex_base_type::ub:
switch (size) switch (size)
{ {
case 1: case 1:
@ -160,9 +160,9 @@ namespace rsx
return sizeof(u8) * 4; return sizeof(u8) * 4;
} }
throw new EXCEPTION("Wrong vector size"); throw new EXCEPTION("Wrong vector size");
case Vertex_base_type::s32k: return sizeof(u32) * size; case vertex_base_type::s32k: return sizeof(u32) * size;
case Vertex_base_type::cmp: return sizeof(u16) * 4; case vertex_base_type::cmp: return sizeof(u16) * 4;
case Vertex_base_type::ub256: return sizeof(u8) * 4; case vertex_base_type::ub256: return sizeof(u8) * 4;
default: default:
throw new EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); throw new EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type);
@ -295,9 +295,9 @@ namespace rsx
surface.unpack(rsx::method_registers[NV4097_SET_SURFACE_FORMAT]); surface.unpack(rsx::method_registers[NV4097_SET_SURFACE_FORMAT]);
draw_state.width = clip_w; draw_state.width = clip_w;
draw_state.height = clip_h; draw_state.height = clip_h;
draw_state.surface_color_format = surface.color_format; draw_state.color_format = surface.color_format;
draw_state.color_buffer = std::move(copy_render_targets_to_memory()); draw_state.color_buffer = std::move(copy_render_targets_to_memory());
draw_state.surface_depth_format = surface.depth_format; draw_state.depth_format = surface.depth_format;
draw_state.depth_stencil = std::move(copy_depth_stencil_buffer_to_memory()); draw_state.depth_stencil = std::move(copy_depth_stencil_buffer_to_memory());
draw_state.programs = get_programs(); draw_state.programs = get_programs();
draw_state.name = name; draw_state.name = name;
@ -495,7 +495,7 @@ namespace rsx
u32 element_size = rsx::get_vertex_type_size_on_host(info.type, info.size); u32 element_size = rsx::get_vertex_type_size_on_host(info.type, info.size);
if (info.type == Vertex_base_type::ub && info.size == 4) if (info.type == vertex_base_type::ub && info.size == 4)
{ {
dst[0] = src[3]; dst[0] = src[3];
dst[1] = src[2]; dst[1] = src[2];

View file

@ -21,9 +21,9 @@ struct frame_capture_data
std::string name; std::string name;
std::pair<std::string, std::string> programs; std::pair<std::string, std::string> programs;
size_t width = 0, height = 0; size_t width = 0, height = 0;
Surface_color_format surface_color_format; surface_color_format color_format;
std::array<std::vector<gsl::byte>, 4> color_buffer; std::array<std::vector<gsl::byte>, 4> color_buffer;
Surface_depth_format surface_depth_format; surface_depth_format depth_format;
std::array<std::vector<gsl::byte>, 2> depth_stencil; std::array<std::vector<gsl::byte>, 2> depth_stencil;
}; };
std::vector<std::pair<u32, u32> > command_queue; std::vector<std::pair<u32, u32> > command_queue;
@ -145,7 +145,7 @@ namespace rsx
static std::string path_to_root(); static std::string path_to_root();
}; };
u32 get_vertex_type_size_on_host(Vertex_base_type type, u32 size); u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size);
u32 get_address(u32 offset, u32 location); u32 get_address(u32 offset, u32 location);
@ -164,9 +164,9 @@ namespace rsx
{ {
u8 log2height; u8 log2height;
u8 log2width; u8 log2width;
Surface_antialiasing antialias; surface_antialiasing antialias;
Surface_depth_format depth_format; surface_depth_format depth_format;
Surface_color_format color_format; surface_color_format color_format;
u32 width; u32 width;
u32 height; u32 height;
@ -192,7 +192,7 @@ namespace rsx
u16 frequency = 0; u16 frequency = 0;
u8 stride = 0; u8 stride = 0;
u8 size = 0; u8 size = 0;
Vertex_base_type type = Vertex_base_type::f; vertex_base_type type = vertex_base_type::f;
void unpack_array(u32 data_array_format) void unpack_array(u32 data_array_format)
{ {
@ -203,6 +203,13 @@ namespace rsx
} }
}; };
enum class draw_command
{
array,
inlined_array,
indexed,
};
class thread : public named_thread_t class thread : public named_thread_t
{ {
protected: protected:
@ -273,13 +280,8 @@ namespace rsx
u32 ctxt_addr; u32 ctxt_addr;
u32 report_main_addr; u32 report_main_addr;
u32 label_addr; u32 label_addr;
enum class Draw_command rsx::draw_command draw_command;
{ primitive_type draw_mode;
draw_command_array,
draw_command_inlined_array,
draw_command_indexed,
} draw_command;
Primitive_type draw_mode;
u32 local_mem_addr, main_mem_addr; u32 local_mem_addr, main_mem_addr;
bool strict_ordering[0x1000]; bool strict_ordering[0x1000];

View file

@ -14,10 +14,10 @@ namespace rsx
rsx_method_t methods[0x10000 >> 2]{}; rsx_method_t methods[0x10000 >> 2]{};
template<typename Type> struct vertex_data_type_from_element_type; template<typename Type> struct vertex_data_type_from_element_type;
template<> struct vertex_data_type_from_element_type<float> { static const Vertex_base_type type = Vertex_base_type::f; }; template<> struct vertex_data_type_from_element_type<float> { static const vertex_base_type type = vertex_base_type::f; };
template<> struct vertex_data_type_from_element_type<f16> { static const Vertex_base_type type = Vertex_base_type::sf; }; template<> struct vertex_data_type_from_element_type<f16> { static const vertex_base_type type = vertex_base_type::sf; };
template<> struct vertex_data_type_from_element_type<u8> { static const Vertex_base_type type = Vertex_base_type::ub; }; template<> struct vertex_data_type_from_element_type<u8> { static const vertex_base_type type = vertex_base_type::ub; };
template<> struct vertex_data_type_from_element_type<u16> { static const Vertex_base_type type = Vertex_base_type::s1; }; template<> struct vertex_data_type_from_element_type<u16> { static const vertex_base_type type = vertex_base_type::s1; };
namespace nv406e namespace nv406e
{ {
@ -160,7 +160,7 @@ namespace rsx
force_inline void draw_arrays(thread* rsx, u32 arg) force_inline void draw_arrays(thread* rsx, u32 arg)
{ {
rsx->draw_command = thread::Draw_command::draw_command_array; rsx->draw_command = rsx::draw_command::array;
u32 first = arg & 0xffffff; u32 first = arg & 0xffffff;
u32 count = (arg >> 24) + 1; u32 count = (arg >> 24) + 1;
@ -169,7 +169,7 @@ namespace rsx
force_inline void draw_index_array(thread* rsx, u32 arg) force_inline void draw_index_array(thread* rsx, u32 arg)
{ {
rsx->draw_command = thread::Draw_command::draw_command_indexed; rsx->draw_command = rsx::draw_command::indexed;
u32 first = arg & 0xffffff; u32 first = arg & 0xffffff;
u32 count = (arg >> 24) + 1; u32 count = (arg >> 24) + 1;
@ -178,7 +178,7 @@ namespace rsx
force_inline void draw_inline_array(thread* rsx, u32 arg) force_inline void draw_inline_array(thread* rsx, u32 arg)
{ {
rsx->draw_command = thread::Draw_command::draw_command_inlined_array; rsx->draw_command = rsx::draw_command::inlined_array;
rsx->draw_inline_vertex_array = true; rsx->draw_inline_vertex_array = true;
rsx->inline_vertex_array.push_back(arg); rsx->inline_vertex_array.push_back(arg);
} }

View file

@ -258,7 +258,7 @@ u8 RescDstFormat2SysutilFormat(u32 dstFormat)
{ {
case CELL_RESC_SURFACE_F_W16Z16Y16X16: case CELL_RESC_SURFACE_F_W16Z16Y16X16:
return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT; return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT;
default: default:
return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8; return CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8;
} }
} }
@ -269,22 +269,22 @@ u8 GcmSurfaceFormat2GcmTextureFormat(u8 surfaceFormat, u8 surfaceType)
switch (to_surface_color_format(surfaceFormat)) switch (to_surface_color_format(surfaceFormat))
{ {
case Surface_color_format::a8r8g8b8: case surface_color_format::a8r8g8b8:
result = CELL_GCM_TEXTURE_A8R8G8B8; result = CELL_GCM_TEXTURE_A8R8G8B8;
break; break;
case Surface_color_format::w16z16y16x16: case surface_color_format::w16z16y16x16:
result = CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT; result = CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT;
break; break;
default: default:
return 0xFF; //Error return 0xFF; //Error
} }
switch (surfaceType) switch (surfaceType)
{ {
case CELL_GCM_SURFACE_PITCH: case CELL_GCM_SURFACE_PITCH:
result |= CELL_GCM_TEXTURE_LN; result |= CELL_GCM_TEXTURE_LN;
break; break;
case CELL_GCM_SURFACE_SWIZZLE: case CELL_GCM_SURFACE_SWIZZLE:
result |= CELL_GCM_TEXTURE_SZ; result |= CELL_GCM_TEXTURE_SZ;
break; break;
default: default:
@ -300,13 +300,13 @@ s32 GetRescDestsIndex(u32 dstMode)
{ {
switch(dstMode) switch(dstMode)
{ {
case CELL_RESC_720x480: case CELL_RESC_720x480:
return 0; return 0;
case CELL_RESC_720x576: case CELL_RESC_720x576:
return 1; return 1;
case CELL_RESC_1280x720: case CELL_RESC_1280x720:
return 2; return 2;
case CELL_RESC_1920x1080: case CELL_RESC_1920x1080:
return 3; return 3;
default: default:
return -1; return -1;
@ -317,14 +317,14 @@ void GetScreenSize(u32 mode, s32 *width, s32 *height)
{ {
switch (mode) switch (mode)
{ {
case CELL_RESC_720x480: case CELL_RESC_720x480:
*width = 720; *height = 480; *width = 720; *height = 480;
break; break;
case CELL_RESC_720x576: case CELL_RESC_720x576:
*width = 720; *height = 576; *width = 720; *height = 576;
break; break;
case CELL_RESC_1280x720: case CELL_RESC_1280x720:
*width = 1280; *height = 720; *width = 1280; *height = 720;
break; break;
case CELL_RESC_1920x1080: case CELL_RESC_1920x1080:
*width = 1920; *height = 1080; *width = 1920; *height = 1080;
@ -935,16 +935,16 @@ s32 cellRescGcmSurface2RescSrc(vm::ptr<CellGcmSurface> gcmSurface, vm::ptr<CellR
switch(to_surface_antialiasing(gcmSurface->antialias)) switch(to_surface_antialiasing(gcmSurface->antialias))
{ {
case Surface_antialiasing::square_rotated_4_samples: case surface_antialiasing::square_rotated_4_samples:
xW=xH=2; xW=xH=2;
break; break;
case Surface_antialiasing::square_centered_4_samples: case surface_antialiasing::square_centered_4_samples:
xW=xH=2; xW=xH=2;
break; break;
case Surface_antialiasing::diagonal_centered_2_samples: case surface_antialiasing::diagonal_centered_2_samples:
xW=2; xW=2;
break; break;
default: default:
break; break;
} }

View file

@ -382,16 +382,16 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
namespace namespace
{ {
std::array<u8, 3> get_value(gsl::span<const gsl::byte> orig_buffer, Surface_color_format format, size_t idx) std::array<u8, 3> get_value(gsl::span<const gsl::byte> orig_buffer, surface_color_format format, size_t idx)
{ {
switch (format) switch (format)
{ {
case Surface_color_format::b8: case surface_color_format::b8:
{ {
u8 value = gsl::as_span<const u8>(orig_buffer)[idx]; u8 value = gsl::as_span<const u8>(orig_buffer)[idx];
return{ value, value, value }; return{ value, value, value };
} }
case Surface_color_format::x32: case surface_color_format::x32:
{ {
be_t<u32> stored_val = gsl::as_span<const be_t<u32>>(orig_buffer)[idx]; be_t<u32> stored_val = gsl::as_span<const be_t<u32>>(orig_buffer)[idx];
u32 swapped_val = stored_val; u32 swapped_val = stored_val;
@ -399,21 +399,21 @@ namespace
u8 val = float_val * 255.f; u8 val = float_val * 255.f;
return{ val, val, val }; return{ val, val, val };
} }
case Surface_color_format::a8b8g8r8: case surface_color_format::a8b8g8r8:
case Surface_color_format::x8b8g8r8_o8b8g8r8: case surface_color_format::x8b8g8r8_o8b8g8r8:
case Surface_color_format::x8b8g8r8_z8b8g8r8: case surface_color_format::x8b8g8r8_z8b8g8r8:
{ {
auto ptr = gsl::as_span<const u8>(orig_buffer); auto ptr = gsl::as_span<const u8>(orig_buffer);
return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] }; return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] };
} }
case Surface_color_format::a8r8g8b8: case surface_color_format::a8r8g8b8:
case Surface_color_format::x8r8g8b8_o8r8g8b8: case surface_color_format::x8r8g8b8_o8r8g8b8:
case Surface_color_format::x8r8g8b8_z8r8g8b8: case surface_color_format::x8r8g8b8_z8r8g8b8:
{ {
auto ptr = gsl::as_span<const u8>(orig_buffer); auto ptr = gsl::as_span<const u8>(orig_buffer);
return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] }; return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] };
} }
case Surface_color_format::w16z16y16x16: case surface_color_format::w16z16y16x16:
{ {
auto ptr = gsl::as_span<const u16>(orig_buffer); auto ptr = gsl::as_span<const u16>(orig_buffer);
f16 h0 = f16(ptr[4 * idx]); f16 h0 = f16(ptr[4 * idx]);
@ -428,11 +428,11 @@ namespace
u8 val2 = f2 * 255.; u8 val2 = f2 * 255.;
return{ val0, val1, val2 }; return{ val0, val1, val2 };
} }
case Surface_color_format::g8b8: case surface_color_format::g8b8:
case Surface_color_format::r5g6b5: case surface_color_format::r5g6b5:
case Surface_color_format::x1r5g5b5_o1r5g5b5: case surface_color_format::x1r5g5b5_o1r5g5b5:
case Surface_color_format::x1r5g5b5_z1r5g5b5: case surface_color_format::x1r5g5b5_z1r5g5b5:
case Surface_color_format::w32z32y32x32: case surface_color_format::w32z32y32x32:
throw EXCEPTION("Unsupported format for display"); throw EXCEPTION("Unsupported format for display");
} }
} }
@ -441,7 +441,7 @@ namespace
* Return a new buffer that can be passed to wxImage ctor. * Return a new buffer that can be passed to wxImage ctor.
* The pointer seems to be freed by wxImage. * The pointer seems to be freed by wxImage.
*/ */
u8* convert_to_wximage_buffer(Surface_color_format format, gsl::span<const gsl::byte> orig_buffer, size_t width, size_t height) noexcept u8* convert_to_wximage_buffer(surface_color_format format, gsl::span<const gsl::byte> orig_buffer, size_t width, size_t height) noexcept
{ {
unsigned char* buffer = (unsigned char*)malloc(width * height * 3); unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
for (u32 i = 0; i < width * height; i++) for (u32 i = 0; i < width * height; i++)
@ -476,7 +476,7 @@ void RSXDebugger::OnClickDrawCalls(wxMouseEvent& event)
{ {
if (width && height && !draw_call.color_buffer[i].empty()) if (width && height && !draw_call.color_buffer[i].empty())
{ {
buffer_img[i] = wxImage(width, height, convert_to_wximage_buffer(draw_call.surface_color_format, draw_call.color_buffer[i], width, height)); buffer_img[i] = wxImage(width, height, convert_to_wximage_buffer(draw_call.color_format, draw_call.color_buffer[i], width, height));
wxClientDC dc_canvas(p_buffers[i]); wxClientDC dc_canvas(p_buffers[i]);
if (buffer_img[i].IsOk()) if (buffer_img[i].IsOk())
@ -491,7 +491,7 @@ void RSXDebugger::OnClickDrawCalls(wxMouseEvent& event)
gsl::span<const gsl::byte> orig_buffer = draw_call.depth_stencil[0]; gsl::span<const gsl::byte> orig_buffer = draw_call.depth_stencil[0];
unsigned char *buffer = (unsigned char *)malloc(width * height * 3); unsigned char *buffer = (unsigned char *)malloc(width * height * 3);
if (draw_call.surface_depth_format == Surface_depth_format::z24s8) if (draw_call.depth_format == surface_depth_format::z24s8)
{ {
for (u32 row = 0; row < height; row++) for (u32 row = 0; row < height; row++)
{ {