/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2017 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_GPU_REGISTERS_H_ #define XENIA_GPU_REGISTERS_H_ #include #include #include "xenia/base/bit_field.h" #include "xenia/gpu/xenos.h" // Most registers can be found from: // https://github.com/UDOOboard/Kernel_Unico/blob/master/drivers/mxc/amd-gpu/include/reg/yamato/14/yamato_registers.h namespace xe { namespace gpu { enum Register { #define XE_GPU_REGISTER(index, type, name) XE_GPU_REG_##name = index, #include "xenia/gpu/register_table.inc" #undef XE_GPU_REGISTER }; namespace reg { /******************************************************************************* ___ ___ _ _ _____ ___ ___ _ / __/ _ \| \| |_ _| _ \/ _ \| | | (_| (_) | .` | | | | / (_) | |__ \___\___/|_|\_| |_| |_|_\\___/|____| *******************************************************************************/ union COHER_STATUS_HOST { xe::bf matching_contexts; xe::bf rb_copy_dest_base_ena; xe::bf dest_base_0_ena; xe::bf dest_base_1_ena; xe::bf dest_base_2_ena; xe::bf dest_base_3_ena; xe::bf dest_base_4_ena; xe::bf dest_base_5_ena; xe::bf dest_base_6_ena; xe::bf dest_base_7_ena; xe::bf vc_action_ena; xe::bf tc_action_ena; xe::bf pglb_action_ena; xe::bf status; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_COHER_STATUS_HOST; }; union WAIT_UNTIL { xe::bf wait_re_vsync; xe::bf wait_fe_vsync; xe::bf wait_vsync; xe::bf wait_dsply_id0; xe::bf wait_dsply_id1; xe::bf wait_dsply_id2; xe::bf wait_cmdfifo; xe::bf wait_2d_idle; xe::bf wait_3d_idle; xe::bf wait_2d_idleclean; xe::bf wait_3d_idleclean; xe::bf cmdfifo_entries; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_WAIT_UNTIL; }; /******************************************************************************* ___ ___ ___ _ _ ___ _ _ ___ ___ ___ / __| __/ _ \| | | | __| \| |/ __| __| _ \ \__ \ _| (_) | |_| | _|| .` | (__| _|| / |___/___\__\_\\___/|___|_|\_|\___|___|_|_\ *******************************************************************************/ union SQ_PROGRAM_CNTL { // Note from a2xx.xml: // Only 0x3F worth of valid register values for VS_NUM_REG and PS_NUM_REG, but // high bit is set to indicate "0 registers used". xe::bf vs_num_reg; xe::bf ps_num_reg; xe::bf vs_resource; xe::bf ps_resource; xe::bf param_gen; xe::bf gen_index_pix; xe::bf vs_export_count; xe::bf vs_export_mode; xe::bf ps_export_mode; xe::bf gen_index_vtx; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_SQ_PROGRAM_CNTL; }; union SQ_CONTEXT_MISC { xe::bf inst_pred_optimize; xe::bf sc_output_screen_xy; xe::bf sc_sample_cntl; xe::bf param_gen_pos; xe::bf perfcounter_ref; xe::bf yeild_optimize; // sic xe::bf tx_cache_sel; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_SQ_CONTEXT_MISC; }; /******************************************************************************* __ _____ ___ _____ _____ __ \ \ / / __| _ \_ _| __\ \/ / \ V /| _|| / | | | _| > < \_/ |___|_|_\ |_| |___/_/\_\ ___ ___ ___ _ _ ___ ___ ___ _ _ _ ___ / __| _ \/ _ \| | | | _ \ __| _ \ /_\ | \| | \ | (_ | / (_) | |_| | _/ _|| / / _ \| .` | |) | \___|_|_\\___/ \___/|_| |___|_|_\ /_/ \_\_|\_|___/ _____ ___ ___ ___ ___ _ _ _ _____ ___ ___ |_ _| __/ __/ __| __| | | | /_\_ _/ _ \| _ \ | | | _|\__ \__ \ _|| |__| |__ / _ \| || (_) | / |_| |___|___/___/___|____|____/_/ \_\_| \___/|_|_\ *******************************************************************************/ union VGT_OUTPUT_PATH_CNTL { xe::bf path_select; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_VGT_OUTPUT_PATH_CNTL; }; union VGT_HOS_CNTL { xe::bf tess_mode; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_VGT_HOS_CNTL; }; /******************************************************************************* ___ ___ ___ __ __ ___ _____ _____ _____ | _ \ _ \_ _| \/ |_ _|_ _|_ _\ \ / / __| | _/ /| || |\/| || | | | | | \ V /| _| |_| |_|_\___|_| |_|___| |_| |___| \_/ |___| _ ___ ___ ___ __ __ ___ _ ___ ___ /_\ / __/ __| __| \/ | _ ) | | __| _ \ / _ \\__ \__ \ _|| |\/| | _ \ |__| _|| / /_/ \_\___/___/___|_| |_|___/____|___|_|_\ *******************************************************************************/ union PA_SU_POINT_MINMAX { // Radius, 12.4 fixed point. xe::bf min_size; xe::bf max_size; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SU_POINT_MINMAX; }; union PA_SU_POINT_SIZE { // 1/2 width or height, 12.4 fixed point. xe::bf height; xe::bf width; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SU_POINT_SIZE; }; // Setup Unit / Scanline Converter mode cntl union PA_SU_SC_MODE_CNTL { xe::bf cull_front; xe::bf cull_back; xe::bf face; xe::bf poly_mode; xe::bf polymode_front_ptype; xe::bf polymode_back_ptype; xe::bf poly_offset_front_enable; xe::bf poly_offset_back_enable; xe::bf poly_offset_para_enable; xe::bf msaa_enable; xe::bf vtx_window_offset_enable; xe::bf line_stipple_enable; xe::bf provoking_vtx_last; xe::bf persp_corr_dis; xe::bf multi_prim_ib_ena; xe::bf quad_order_enable; xe::bf wait_rb_idle_all_tri; xe::bf wait_rb_idle_first_tri_new_state; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SU_SC_MODE_CNTL; }; // Setup Unit Vertex Control union PA_SU_VTX_CNTL { xe::bf pix_center; // 1 = half pixel offset xe::bf round_mode; xe::bf quant_mode; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SU_VTX_CNTL; }; union PA_SC_MPASS_PS_CNTL { xe::bf mpass_pix_vec_per_pass; xe::bf mpass_ps_ena; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SC_MPASS_PS_CNTL; }; // Scanline converter viz query union PA_SC_VIZ_QUERY { xe::bf viz_query_ena; xe::bf viz_query_id; xe::bf kill_pix_post_early_z; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SC_VIZ_QUERY; }; // Clipper clip control union PA_CL_CLIP_CNTL { xe::bf ucp_ena_0; xe::bf ucp_ena_1; xe::bf ucp_ena_2; xe::bf ucp_ena_3; xe::bf ucp_ena_4; xe::bf ucp_ena_5; xe::bf ps_ucp_mode; xe::bf clip_disable; xe::bf ucp_cull_only_ena; xe::bf boundary_edge_flag_ena; xe::bf dx_clip_space_def; xe::bf dis_clip_err_detect; xe::bf vtx_kill_or; xe::bf xy_nan_retain; xe::bf z_nan_retain; xe::bf w_nan_retain; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_CL_CLIP_CNTL; }; // Viewport transform engine control union PA_CL_VTE_CNTL { xe::bf vport_x_scale_ena; xe::bf vport_x_offset_ena; xe::bf vport_y_scale_ena; xe::bf vport_y_offset_ena; xe::bf vport_z_scale_ena; xe::bf vport_z_offset_ena; xe::bf vtx_xy_fmt; xe::bf vtx_z_fmt; xe::bf vtx_w0_fmt; xe::bf perfcounter_ref; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_CL_VTE_CNTL; }; union PA_SC_WINDOW_OFFSET { xe::bf window_x_offset; xe::bf window_y_offset; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SC_WINDOW_OFFSET; }; union PA_SC_WINDOW_SCISSOR_TL { xe::bf tl_x; xe::bf tl_y; xe::bf window_offset_disable; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SC_WINDOW_SCISSOR_TL; }; union PA_SC_WINDOW_SCISSOR_BR { xe::bf br_x; xe::bf br_y; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_PA_SC_WINDOW_SCISSOR_BR; }; /******************************************************************************* ___ ___ | _ \ _ ) | / _ \ |_|_\___/ *******************************************************************************/ union RB_MODECONTROL { xe::bf edram_mode; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_MODECONTROL; }; union RB_SURFACE_INFO { xe::bf surface_pitch; xe::bf msaa_samples; xe::bf hiz_pitch; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_SURFACE_INFO; }; union RB_COLORCONTROL { xe::bf alpha_func; xe::bf alpha_test_enable; xe::bf alpha_to_mask_enable; // Everything in between was added on Adreno, not in game PDBs and never set. xe::bf alpha_to_mask_offset0; xe::bf alpha_to_mask_offset1; xe::bf alpha_to_mask_offset2; xe::bf alpha_to_mask_offset3; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COLORCONTROL; }; union RB_COLOR_INFO { xe::bf color_base; xe::bf color_format; xe::bf color_exp_bias; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COLOR_INFO; // RB_COLOR[1-3]_INFO also use this format. }; union RB_COLOR_MASK { xe::bf write_red0; xe::bf write_green0; xe::bf write_blue0; xe::bf write_alpha0; xe::bf write_red1; xe::bf write_green1; xe::bf write_blue1; xe::bf write_alpha1; xe::bf write_red2; xe::bf write_green2; xe::bf write_blue2; xe::bf write_alpha2; xe::bf write_red3; xe::bf write_green3; xe::bf write_blue3; xe::bf write_alpha3; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COLOR_MASK; }; union RB_DEPTHCONTROL { xe::bf stencil_enable; xe::bf z_enable; xe::bf z_write_enable; // EARLY_Z_ENABLE was added on Adreno. xe::bf zfunc; xe::bf backface_enable; xe::bf stencilfunc; xe::bf stencilfail; xe::bf stencilzpass; xe::bf stencilzfail; xe::bf stencilfunc_bf; xe::bf stencilfail_bf; xe::bf stencilzpass_bf; xe::bf stencilzfail_bf; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_DEPTHCONTROL; }; union RB_STENCILREFMASK { xe::bf stencilref; xe::bf stencilmask; xe::bf stencilwritemask; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_STENCILREFMASK; // RB_STENCILREFMASK_BF also uses this format. }; union RB_DEPTH_INFO { xe::bf depth_base; xe::bf depth_format; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_DEPTH_INFO; }; union RB_COPY_CONTROL { xe::bf copy_src_select; xe::bf copy_sample_select; xe::bf color_clear_enable; xe::bf depth_clear_enable; xe::bf copy_command; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COPY_CONTROL; }; union RB_COPY_DEST_INFO { xe::bf copy_dest_endian; xe::bf copy_dest_array; xe::bf copy_dest_slice; xe::bf copy_dest_format; xe::bf copy_dest_number; xe::bf copy_dest_exp_bias; xe::bf copy_dest_swap; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COPY_DEST_INFO; }; union RB_COPY_DEST_PITCH { xe::bf copy_dest_pitch; xe::bf copy_dest_height; uint32_t value; static constexpr uint32_t register_index = XE_GPU_REG_RB_COPY_DEST_PITCH; }; } // namespace reg } // namespace gpu } // namespace xe #endif // XENIA_GPU_REGISTERS_H_