From 07b3897499a0b70ae5ee7c1267e7620acb0ee3af Mon Sep 17 00:00:00 2001 From: DH Date: Tue, 13 Oct 2015 20:44:58 +0300 Subject: [PATCH] Trying do not use macro for methods binding to range --- rpcs3/Emu/RSX/RSXThread.cpp | 225 ++++++++++++++++++------------------ 1 file changed, 114 insertions(+), 111 deletions(-) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 21562f44f2..16af011c9c 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -105,54 +105,78 @@ namespace rsx } template - force_inline void set_vertex_data4ub_m(thread* rsx, u32 arg) + struct set_vertex_data4ub_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data1f_m(thread* rsx, u32 arg) + struct set_vertex_data1f_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data2f_m(thread* rsx, u32 arg) + struct set_vertex_data2f_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data3f_m(thread* rsx, u32 arg) + struct set_vertex_data3f_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data4f_m(thread* rsx, u32 arg) + struct set_vertex_data4f_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data2s_m(thread* rsx, u32 arg) + struct set_vertex_data2s_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data4s_m(thread* rsx, u32 arg) + struct set_vertex_data4s_m { - set_vertex_data_impl(rsx, arg); - } + force_inline static void impl(thread* rsx, u32 arg) + { + set_vertex_data_impl(rsx, arg); + } + }; template - force_inline void set_vertex_data_array_format(thread* rsx, u32 arg) + struct set_vertex_data_array_format { - auto& info = rsx->vertex_arrays_info[index]; - info.unpack(arg); - info.array = info.size > 0; - } + force_inline static void impl(thread* rsx, u32 arg) + { + auto& info = rsx->vertex_arrays_info[index]; + info.unpack(arg); + info.array = info.size > 0; + } + }; force_inline void draw_arrays(thread* rsx, u32 arg) { @@ -172,26 +196,32 @@ namespace rsx } template - force_inline void set_transform_constant(thread* rsxthr, u32 arg) + struct set_transform_constant { - u32& load = method_registers[NV4097_SET_TRANSFORM_CONSTANT_LOAD]; + force_inline static void impl(thread* rsxthr, u32 arg) + { + u32& load = method_registers[NV4097_SET_TRANSFORM_CONSTANT_LOAD]; - static const size_t count = 4; - static const size_t size = count * sizeof(f32); + static const size_t count = 4; + static const size_t size = count * sizeof(f32); - memcpy(rsxthr->transform_constants[load++].rgba, method_registers + NV4097_SET_TRANSFORM_CONSTANT + index * count, size); - } + memcpy(rsxthr->transform_constants[load++].rgba, method_registers + NV4097_SET_TRANSFORM_CONSTANT + index * count, size); + } + }; template - force_inline void set_transform_program(thread* rsx, u32 arg) + struct set_transform_program { - u32& load = method_registers[NV4097_SET_TRANSFORM_PROGRAM_LOAD]; + force_inline static void impl(thread* rsx, u32 arg) + { + u32& load = method_registers[NV4097_SET_TRANSFORM_PROGRAM_LOAD]; - static const size_t count = 4; - static const size_t size = count * sizeof(u32); + static const size_t count = 4; + static const size_t size = count * sizeof(u32); - memcpy(rsx->transform_program + load++ * count, method_registers + NV4097_SET_TRANSFORM_PROGRAM + index * count, size); - } + memcpy(rsx->transform_program + load++ * count, method_registers + NV4097_SET_TRANSFORM_PROGRAM + index * count, size); + } + }; force_inline void set_begin_end(thread* rsx, u32 arg) { @@ -291,20 +321,23 @@ namespace rsx namespace nv308a { template - force_inline void color(u32 arg) + struct color { - u32 point = method_registers[NV308A_POINT]; - u16 x = point; - u16 y = point >> 16; - - if (y) + force_inline static void impl(u32 arg) { - LOG_ERROR(RSX, "%s: y is not null (0x%x)", __FUNCTION__, y); - } + u32 point = method_registers[NV308A_POINT]; + u16 x = point; + u16 y = point >> 16; - u32 address = get_address(method_registers[NV3062_SET_OFFSET_DESTIN] + (x << 2) + index * 4, method_registers[NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN]); - vm::write32(address, arg); - } + if (y) + { + LOG_ERROR(RSX, "%s: y is not null (0x%x)", __FUNCTION__, y); + } + + u32 address = get_address(method_registers[NV3062_SET_OFFSET_DESTIN] + (x << 2) + index * 4, method_registers[NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN]); + vm::write32(address, arg); + } + }; } namespace nv3089 @@ -451,7 +484,7 @@ namespace rsx if (y >= 0 && y < std::min(method_registers[NV3089_CLIP_SIZE] >> 16, out_h)) { // source line - u8* src_line = pixels_src + y * out_bpp * out_w + + u8* src_line = pixels_src + y * out_bpp * out_w + std::min(std::max(method_registers[NV3089_CLIP_POINT] & 0xffff, 0), method_registers[NV3089_CLIP_SIZE] & 0xffff); size_t src_max = std::min( std::max((s32)(method_registers[NV3089_CLIP_SIZE] & 0xffff) - (method_registers[NV3089_CLIP_POINT] & 0xffff), 0), @@ -585,23 +618,30 @@ namespace rsx call_impl_func(rsx, arg); } - /* - template class T, T impl_func = nullptr, int limit = 0> - static void bind_impl() + template class T, int index = 0> + struct bind_range_impl_t { - bind>(); + force_inline static void impl() + { + bind_range_impl_t::impl(); + bind::impl>(); + } + }; - if (id + step < limit) - bind_impl(); + template class T> + struct bind_range_impl_t + { + force_inline static void impl() + { + } + }; + + template class T, int index = 0> + force_inline static void bind_range() + { + bind_range_impl_t::impl(); } - template class rsx_impl_method_t impl_func = nullptr> - static void bind() { bind_impl(); } - - template class rsx_method_t impl_func = nullptr> - static void bind() { bind_impl(); } - */ - template static void bind_impl() { @@ -632,42 +672,6 @@ namespace rsx //do not try process on gpu template static void bind_cpu_only() { bind_cpu_only_impl(); } -#define bind_2(index, offset, step, func) \ - bind>(); \ - bind>() - -#define bind_4(index, offset, step, func) \ - bind_2(index, offset, step, func); \ - bind_2(index + 2, offset + 2*step, step, func) - -#define bind_8(index, offset, step, func) \ - bind_4(index, offset, step, func); \ - bind_4(index + 4, offset + 4*step, step, func) - -#define bind_16(index, offset, step, func) \ - bind_8(index, offset, step, func); \ - bind_8(index + 8, offset + 8*step, step, func) - -#define bind_32(index, offset, step, func) \ - bind_16(index, offset, step, func); \ - bind_16(index + 16, offset + 16*step, step, func) - -#define bind_64(index, offset, step, func) \ - bind_32(index, offset, step, func); \ - bind_32(index + 32, offset + 32*step, step, func) - -#define bind_128(index, offset, step, func) \ - bind_64(index, offset, step, func); \ - bind_64(index + 64, offset + 64*step, step, func) - -#define bind_256(index, offset, step, func) \ - bind_128(index, offset, step, func); \ - bind_128(index + 128, offset + 128*step, step, func) - -#define bind_512(index, offset, step, func) \ - bind_256(index, offset, step, func); \ - bind_256(index + 256, offset + 256*step, step, func) - __rsx_methods_t() { // NV406E @@ -682,22 +686,21 @@ namespace rsx bind(); bind(); bind(); - //bind(); - bind_16(0, NV4097_SET_VERTEX_DATA_ARRAY_FORMAT, 1, nv4097::set_vertex_data_array_format); - bind_16(0, NV4097_SET_VERTEX_DATA4UB_M, 1, nv4097::set_vertex_data4ub_m); - bind_16(0, NV4097_SET_VERTEX_DATA1F_M, 1, nv4097::set_vertex_data1f_m); - bind_16(0, NV4097_SET_VERTEX_DATA2F_M + 1, 2, nv4097::set_vertex_data2f_m); - bind_16(0, NV4097_SET_VERTEX_DATA3F_M + 2, 3, nv4097::set_vertex_data3f_m); - bind_16(0, NV4097_SET_VERTEX_DATA4F_M + 3, 4, nv4097::set_vertex_data4f_m); - bind_16(0, NV4097_SET_VERTEX_DATA2S_M, 1, nv4097::set_vertex_data2s_m); - bind_16(0, NV4097_SET_VERTEX_DATA4S_M + 1, 2, nv4097::set_vertex_data4s_m); - bind_8(0, NV4097_SET_TRANSFORM_CONSTANT + 3, 4, nv4097::set_transform_constant); - bind_128(0, NV4097_SET_TRANSFORM_PROGRAM + 3, 4, nv4097::set_transform_program); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); + bind_range(); bind_cpu_only(); bind_cpu_only(); //NV308A - bind_512(0, NV308A_COLOR, 1, nv308a::color); + bind_range(); //NV3089 bind();