Skip to content

Commit

Permalink
Updated c_rasterizer functions
Browse files Browse the repository at this point in the history
Moved `k_main_event_reason_description` to the top of its file
  • Loading branch information
twist84 committed Jan 8, 2025
1 parent 70bb002 commit a2b41d3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 68 deletions.
12 changes: 6 additions & 6 deletions game/source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ HOOK_DECLARE(0x00506A10, main_prepare_for_switch_zone_set);
HOOK_DECLARE(0x00507210, main_switch_zone_set);
HOOK_DECLARE(0x00507450, process_published_game_state);

char const* const k_main_event_reason_description[k_number_of_main_reset_event_reasons]
{
"changing the map",
"xsync in progress"
};

bool g_fake_minidump_creation = true;
bool g_suppress_keyboard_for_minidump = false;
char const* const k_crash_info_output_filename = "crash_report\\crash_info.txt";
Expand Down Expand Up @@ -333,12 +339,6 @@ bool __cdecl main_events_pending()
return result;
}

char const* const k_main_event_reason_description[k_number_of_main_reset_event_reasons]
{
"changing the map",
"xsync in progress"
};

void __cdecl main_events_reset(e_main_reset_events_reason reason)
{
//INVOKE(0x00505650, main_events_reset, reason);
Expand Down
99 changes: 54 additions & 45 deletions game/source/rasterizer/rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,9 +1198,10 @@ bool __cdecl c_rasterizer::set_pixel_shader(c_rasterizer_pixel_shader const* pix
//return true;
}

void __cdecl c_rasterizer::set_aliased_surface_as_texture(long sampler_index, e_surface surface)
// its possible this name is incorrect but also more accurate than the previous name `c_rasterizer::set_aliased_surface_as_texture`
void __cdecl c_rasterizer::set_sampler_texture_direct(long sampler_index, e_surface surface)
{
INVOKE(0x00A23530, c_rasterizer::set_aliased_surface_as_texture, sampler_index, surface);
INVOKE(0x00A23530, c_rasterizer::set_sampler_texture_direct, sampler_index, surface);
}

void __cdecl c_rasterizer::set_sampler_address_mode(long sampler_index, e_sampler_address_mode sampler_address_mode)
Expand Down Expand Up @@ -1471,9 +1472,14 @@ void __cdecl c_rasterizer::setup_occlusion_state()
//}
}

void __cdecl c_rasterizer::setup_render_target_globals_with_exposure(real a1, real a2, bool a3)
void __cdecl c_rasterizer::setup_render_target_globals_with_exposure(real view_exposure, real illum_scale, real HDR_target_stops, bool alpha_blend)
{
INVOKE(0x00A24B90, c_rasterizer::setup_render_target_globals_with_exposure, a1, a2, a3);
INVOKE(0x00A24B90, c_rasterizer::setup_render_target_globals_with_exposure, view_exposure, illum_scale, HDR_target_stops, alpha_blend);
}

void __cdecl c_rasterizer::setup_render_target_globals_with_exposure_for_texture_camera_only(real view_exposure, real illum_scale, real HDR_target_stops, bool alpha_blend)
{
INVOKE(0x00A24C60, c_rasterizer::setup_render_target_globals_with_exposure_for_texture_camera_only, view_exposure, illum_scale, HDR_target_stops, alpha_blend);
}

void __cdecl c_rasterizer::setup_targets_albedo(bool clear_stencil, bool is_clear)
Expand Down Expand Up @@ -1520,18 +1526,18 @@ void __cdecl c_rasterizer::setup_targets_albedo(bool clear_stencil, bool is_clea
//}
}

void __cdecl c_rasterizer::setup_targets_distortion(short_rectangle2d* bounds)
void __cdecl c_rasterizer::setup_targets_distortion(short_rectangle2d* pixel_bounds, bool depth_test)
{
INVOKE(0x00A250D0, c_rasterizer::setup_targets_distortion, bounds);
INVOKE(0x00A250D0, c_rasterizer::setup_targets_distortion, pixel_bounds, depth_test);

//set_depth_stencil_surface(_surface_depth_stencil);
//set_render_target(0, _surface_distortion, 0xFFFFFFFF);
//set_render_target(1, _surface_none, 0xFFFFFFFF);
//set_render_target(2, _surface_none, 0xFFFFFFFF);
//set_render_target(3, _surface_none, 0xFFFFFFFF);
//clearf(1, 0x808000, 0.0f, 0);
//set_viewport(bounds, 0.0f, 1.0f);
//set_scissor_rect(bounds);
//set_viewport(pixel_bounds, 0.0f, 1.0f);
//set_scissor_rect(pixel_bounds);
}

void __cdecl c_rasterizer::setup_targets_simple()
Expand All @@ -1548,14 +1554,14 @@ void __cdecl c_rasterizer::setup_targets_simple()
//}
}

void __cdecl c_rasterizer::setup_targets_static_lighting(real a1, real a2, bool a3, real a4, bool a5, bool a6, bool a7)
void __cdecl c_rasterizer::setup_targets_static_lighting(real view_exposure, real illum_scale, bool render_to_HDR_target, real HDR_target_stops, bool clear, bool copy_albedo_pc, bool a7)
{
INVOKE(0x00A252C0, c_rasterizer::setup_targets_static_lighting, a1, a2, a3, a4, a5, a6, a7);
INVOKE(0x00A252C0, c_rasterizer::setup_targets_static_lighting, view_exposure, illum_scale, render_to_HDR_target, HDR_target_stops, clear, copy_albedo_pc, a7);
}

void __cdecl c_rasterizer::setup_targets_static_lighting_alpha_blend(bool a1, bool a2)
void __cdecl c_rasterizer::setup_targets_static_lighting_alpha_blend(bool render_to_HDR_target, bool alpha_blend)
{
INVOKE(0x00A25400, c_rasterizer::setup_targets_static_lighting_alpha_blend, a1, a2);
INVOKE(0x00A25400, c_rasterizer::setup_targets_static_lighting_alpha_blend, render_to_HDR_target, alpha_blend);
}

void __cdecl c_rasterizer::draw_indexed_primitive(c_rasterizer_index_buffer const* indices, long base_vertex_index, long num_vertices, long min_index, long triangle_count)
Expand Down Expand Up @@ -1589,12 +1595,12 @@ void __cdecl c_rasterizer::set_current_splitscreen_res(e_splitscreen_res splitsc
//c_rasterizer::set_depth_stencil_surface(c_rasterizer::g_depth_stencil_surface);
}

c_rasterizer::e_surface __cdecl c_rasterizer::get_render_target(long render_target_index)
c_rasterizer::e_surface __cdecl c_rasterizer::get_render_target(long surface_index)
{
return INVOKE(0x00A48720, c_rasterizer::get_render_target, render_target_index);
return INVOKE(0x00A48720, c_rasterizer::get_render_target, surface_index);
}

//.text:00A48730 ; public: static real __cdecl c_rasterizer::get_render_target_alpha_multiplier(long a1)
//.text:00A48730 ; public: static real __cdecl c_rasterizer::get_render_target_alpha_multiplier(long surface_index)

c_rasterizer::e_surface c_rasterizer::sub_A48770()
{
Expand All @@ -1609,80 +1615,83 @@ void __cdecl c_rasterizer::resolve_entire_surface(e_surface surface, long a2, sh
//INVOKE(0x00A48C50, c_rasterizer::resolve_entire_surface, surface, a2, a3, a4, a5);
}

void __cdecl c_rasterizer::set_depth_stencil_surface(e_surface surface)
void __cdecl c_rasterizer::set_depth_stencil_surface(e_surface depth_stencil)
{
INVOKE(0x00A48CB0, c_rasterizer::set_depth_stencil_surface, surface);
INVOKE(0x00A48CB0, c_rasterizer::set_depth_stencil_surface, depth_stencil);
}

void __cdecl c_rasterizer::set_render_target(long render_target_index, e_surface surface, long render_state)
void __cdecl c_rasterizer::set_render_target(long surface_index, e_surface surface, long force_is_srgb)
{
INVOKE(0x00A48E40, c_rasterizer::set_render_target, render_target_index, surface, render_state);
INVOKE(0x00A48E40, c_rasterizer::set_render_target, surface_index, surface, force_is_srgb);
}

void __cdecl c_rasterizer::set_using_albedo_sampler(bool using_albedo_sampler)
void __cdecl c_rasterizer::set_using_albedo_sampler(bool value)
{
INVOKE(0x00A48FE0, c_rasterizer::set_using_albedo_sampler, using_albedo_sampler);
INVOKE(0x00A48FE0, c_rasterizer::set_using_albedo_sampler, value);
}

void __cdecl c_rasterizer::set_viewport(short_rectangle2d const& viewport, real min_z, real max_z)
void __cdecl c_rasterizer::set_viewport(short_rectangle2d const& viewport_bounds, real minz, real maxz)
{
//INVOKE(0x00A49010, c_rasterizer::set_viewport, viewport, z_min, z_max);
//INVOKE(0x00A49010, c_rasterizer::set_viewport, viewport_bounds, minz, maxz);

D3DVIEWPORT9 d3d_viewport
D3DVIEWPORT9 viewport
{
.X = (DWORD)viewport.x0,
.Y = (DWORD)viewport.y0,
.Width = DWORD(viewport.x1 - viewport.x0),
.Height = DWORD(viewport.y1 - viewport.y0),
.MinZ = min_z,
.MaxZ = max_z
.X = (DWORD)viewport_bounds.x0,
.Y = (DWORD)viewport_bounds.y0,
.Width = DWORD(viewport_bounds.x1 - viewport_bounds.x0),
.Height = DWORD(viewport_bounds.y1 - viewport_bounds.y0),
.MinZ = minz,
.MaxZ = maxz
};
c_rasterizer::g_device->SetViewport(&d3d_viewport);
c_rasterizer::g_device->SetViewport(&viewport);
}

void __cdecl c_rasterizer::wait_for_gpu_idle()
{
//INVOKE(0x00A49130, c_rasterizer::wait_for_gpu_idle);
}

void __cdecl c_rasterizer::set_pixel_shader_constant(long start_register, long vector4f_count, real_vector4d const* constant_data)
void __cdecl c_rasterizer::set_pixel_shader_constant(long constant_index, long count, real_vector4d const* constants)
{
INVOKE(0x00A66270, c_rasterizer::set_pixel_shader_constant, start_register, vector4f_count, constant_data);
INVOKE(0x00A66270, c_rasterizer::set_pixel_shader_constant, constant_index, count, constants);
}

void __cdecl c_rasterizer::set_pixel_shader_constant_bool(long start_register, long bool_count, int const* constant_data)
void __cdecl c_rasterizer::set_pixel_shader_constant_bool(long constant_index, long count, int const* constants)
{
INVOKE(0x00A66370, c_rasterizer::set_pixel_shader_constant_bool, start_register, bool_count, constant_data);
INVOKE(0x00A66370, c_rasterizer::set_pixel_shader_constant_bool, constant_index, count, constants);
}

void __cdecl c_rasterizer::set_pixel_shader_constant_int(long start_register, long vector4i_count, int const* constant_data)
void __cdecl c_rasterizer::set_pixel_shader_constant_int(long constant_index, long vector_count, int const* constants)
{
INVOKE(0x00A663A0, c_rasterizer::set_pixel_shader_constant_int, start_register, vector4i_count, constant_data);
INVOKE(0x00A663A0, c_rasterizer::set_pixel_shader_constant_int, constant_index, vector_count, constants);
}

void __cdecl c_rasterizer::set_pixel_shader_constant_single(long start_register, real constant_value)
void __cdecl c_rasterizer::set_pixel_shader_constant_single(long constant_index, real value)
{
INVOKE(0x00A663C0, c_rasterizer::set_pixel_shader_constant_single, start_register, constant_value);
INVOKE(0x00A663C0, c_rasterizer::set_pixel_shader_constant_single, constant_index, value);
}

//.text:00A66400 ;

void __cdecl c_rasterizer::set_vertex_shader_constant(long start_register, long vector4f_count, real_vector4d const* constant_data)
void __cdecl c_rasterizer::set_vertex_shader_constant(long constant_index, long vector_count, real_vector4d const* constants)
{
INVOKE(0x00A66410, c_rasterizer::set_vertex_shader_constant, start_register, vector4f_count, constant_data);
INVOKE(0x00A66410, c_rasterizer::set_vertex_shader_constant, constant_index, vector_count, constants);
}

void __cdecl c_rasterizer::set_vertex_shader_constant_bool(long start_register, long bool_count, int const* constant_data)
void __cdecl c_rasterizer::set_vertex_shader_constant_bool(long constant_index, long count, int const* constants)
{
INVOKE(0x00A66370, c_rasterizer::set_vertex_shader_constant_bool, start_register, bool_count, constant_data);
INVOKE(0x00A66620, c_rasterizer::set_vertex_shader_constant_bool, constant_index, count, constants);
}

void __cdecl c_rasterizer::set_vertex_shader_constant_int(long start_register, long vector4i_count, int const* constant_data)
{
INVOKE(0x00A663A0, c_rasterizer::set_vertex_shader_constant_int, start_register, vector4i_count, constant_data);
INVOKE(0x00A66640, c_rasterizer::set_vertex_shader_constant_int, start_register, vector4i_count, constant_data);
}

//.text:00A66660 ;
void __cdecl c_rasterizer::set_vertex_shader_constant_owned(long constant_index, long count, real_vector4d const* constants)
{
INVOKE(0x00A66660, c_rasterizer::set_vertex_shader_constant_owned, constant_index, count, constants);
}

HBITMAP create_bitmap_handle(HWND window_handle)
{
Expand Down
32 changes: 17 additions & 15 deletions game/source/rasterizer/rasterizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ struct c_rasterizer
static void __cdecl set_fill_mode(e_fill_mode);
static void __cdecl set_indices(IDirect3DIndexBuffer9*);
static bool __cdecl set_pixel_shader(c_rasterizer_pixel_shader const*, e_entry_point);
static void __cdecl set_aliased_surface_as_texture(long, e_surface);
static void __cdecl set_sampler_texture_direct(long, e_surface);
static void __cdecl set_sampler_address_mode(long, e_sampler_address_mode);
static void __cdecl set_sampler_filter_mode(long, e_sampler_filter_mode);
static void __cdecl set_sampler_texture(long, c_rasterizer_texture_ref);
Expand All @@ -373,12 +373,13 @@ struct c_rasterizer
static bool __cdecl get_is_using_floating_point_depth_buffer();

static void __cdecl setup_occlusion_state();
static void __cdecl setup_render_target_globals_with_exposure(real, real, bool);
static void __cdecl setup_render_target_globals_with_exposure(real view_exposure, real illum_scale, real HDR_target_stops, bool alpha_blend);
static void __cdecl setup_render_target_globals_with_exposure_for_texture_camera_only(real view_exposure, real illum_scale, real HDR_target_stops, bool alpha_blend);
static void __cdecl setup_targets_albedo(bool clear_stencil, bool is_clear);
static void __cdecl setup_targets_distortion(short_rectangle2d*);
static void __cdecl setup_targets_distortion(short_rectangle2d* pixel_bounds, bool depth_test);
static void __cdecl setup_targets_simple();
static void __cdecl setup_targets_static_lighting(real a1, real a2, bool a3, real a4, bool a5, bool a6, bool a7);
static void __cdecl setup_targets_static_lighting_alpha_blend(bool, bool);
static void __cdecl setup_targets_static_lighting(real view_exposure, real illum_scale, bool render_to_HDR_target, real HDR_target_stops, bool clear, bool copy_albedo_pc, bool a7);
static void __cdecl setup_targets_static_lighting_alpha_blend(bool render_to_HDR_target, bool alpha_blend);

static void __cdecl draw_indexed_primitive(c_rasterizer_index_buffer const* indices, long base_vertex_index, long num_vertices, long min_index, long triangle_count);
static void __cdecl draw_primitive(c_rasterizer_index_buffer::e_primitive_type primitive_type, long start_vertex, long primitive_count);
Expand All @@ -387,14 +388,14 @@ struct c_rasterizer

static void __cdecl set_current_splitscreen_res(e_splitscreen_res splitscreen_res);

static e_surface __cdecl get_render_target(long render_target_index);
static e_surface __cdecl get_render_target(long surface_index);

static e_surface sub_A48770();

static void __cdecl resolve_entire_surface(e_surface surface, long a2, short_rectangle2d* a3, short a4, short a5);
static void __cdecl set_depth_stencil_surface(e_surface surface);
static void __cdecl set_render_target(long render_target_index, e_surface surface, long render_state);
static void __cdecl set_using_albedo_sampler(bool using_albedo_sampler);
static void __cdecl set_depth_stencil_surface(e_surface depth_stencil);
static void __cdecl set_render_target(long surface_index, e_surface surface, long force_is_srgb);
static void __cdecl set_using_albedo_sampler(bool value);
static void __cdecl set_viewport(short_rectangle2d const& viewport, real min_z, real max_z);
static void __cdecl wait_for_gpu_idle();

Expand All @@ -415,13 +416,14 @@ struct c_rasterizer
static void __cdecl draw_worldspace_polygon(real_point3d const* worldspace_polygon, long polygon_count);
static void __cdecl draw_worldspace_polygon(rasterizer_vertex_world const* worldspace_polygon, long polygon_count);

static void __cdecl set_pixel_shader_constant(long start_register, long vector4f_count, real_vector4d const* constant_data);
static void __cdecl set_pixel_shader_constant_bool(long start_register, long bool_count, int const* constant_data);
static void __cdecl set_pixel_shader_constant_int(long start_register, long vector4i_count, int const* constant_data);
static void __cdecl set_pixel_shader_constant_single(long start_register, real constant_value);
static void __cdecl set_vertex_shader_constant(long start_register, long vector4f_count, real_vector4d const* constant_data);
static void __cdecl set_vertex_shader_constant_bool(long start_register, long bool_count, int const* constant_data);
static void __cdecl set_pixel_shader_constant(long constant_index, long count, real_vector4d const* constants);
static void __cdecl set_pixel_shader_constant_bool(long constant_index, long count, int const* constants);
static void __cdecl set_pixel_shader_constant_int(long constant_index, long vector_count, int const* constants);
static void __cdecl set_pixel_shader_constant_single(long constant_index, real value);
static void __cdecl set_vertex_shader_constant(long constant_index, long vector_count, real_vector4d const* constants);
static void __cdecl set_vertex_shader_constant_bool(long constant_index, long count, int const* constants);
static void __cdecl set_vertex_shader_constant_int(long start_register, long vector4i_count, int const* constant_data);
static void __cdecl set_vertex_shader_constant_owned(long constant_index, long count, real_vector4d const* constants);

static bool& g_d3d_device_is_lost;
static bool& g_d3d_device_reset;
Expand Down
4 changes: 2 additions & 2 deletions game/source/render/views/render_player_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void __thiscall c_player_view::render_1st_pass()
if (chud_generate_damage_flash_texture(m_camera_user_data.user_index))
{
c_rasterizer::setup_targets_static_lighting_alpha_blend(false, true);
c_rasterizer::setup_render_target_globals_with_exposure(1.0f, 1.0f, 1.0f);
c_rasterizer::setup_render_target_globals_with_exposure(1.0f, 1.0f, 1.0f, true);
c_rasterizer::set_render_target(1, c_rasterizer::_surface_none, 0xFFFFFFFF);
chud_draw_screen_LDR(m_camera_user_data.user_index);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ void __thiscall c_player_view::render_3rd_pass()

c_rasterizer::restore_last_viewport();
c_rasterizer::restore_last_scissor_rect();
c_rasterizer::setup_render_target_globals_with_exposure(1.0f, 1.0f, 1.0f);
c_rasterizer::setup_render_target_globals_with_exposure(1.0f, 1.0f, 1.0f, true);

s_screen_effect_settings screen_effect_settings{};
s_screen_effect_shader_sample_result screen_effect_shader_sample_result{};
Expand Down

0 comments on commit a2b41d3

Please sign in to comment.