Skip to content

Commit

Permalink
Added more d3d pix events
Browse files Browse the repository at this point in the history
`lightshafts`
`lens flares`
`render_misc_transparents`
`transparents`
  • Loading branch information
twist84 committed Nov 7, 2024
1 parent 868b4c9 commit 61a185d
Show file tree
Hide file tree
Showing 20 changed files with 264 additions and 23 deletions.
2 changes: 2 additions & 0 deletions game/game.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
<ClCompile Include="source\rasterizer\rasterizer_dynamic_render_targets.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_loading_screen.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_memory.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_occlusion_queries.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_profile.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_render_targets.cpp" />
<ClCompile Include="source\rasterizer\rasterizer_stipple.cpp" />
Expand Down Expand Up @@ -1151,6 +1152,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
<ClInclude Include="source\rasterizer\rasterizer_dynamic_render_targets.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_loading_screen.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_memory.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_occlusion_queries.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_profile.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_render_targets.hpp" />
<ClInclude Include="source\rasterizer\rasterizer_stipple.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions game/game.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,9 @@
<ClCompile Include="source\rasterizer\rasterizer_stipple.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\rasterizer\rasterizer_occlusion_queries.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\camera\camera.hpp">
Expand Down Expand Up @@ -3926,6 +3929,9 @@
<ClInclude Include="source\rasterizer\rasterizer_stipple.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\rasterizer\rasterizer_occlusion_queries.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource\resource.rc">
Expand Down
1 change: 1 addition & 0 deletions game/source/memory/thread_local.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "rasterizer/rasterizer_hue_saturation.hpp"
#include "rasterizer/rasterizer_implicit_geometry.hpp"
#include "rasterizer/rasterizer_main.hpp"
#include "render/camera_fx_settings.hpp"
#include "render/depth_of_field.hpp"
#include "render/render_game_state.hpp"
#include "render/render_objects.hpp"
Expand Down
15 changes: 13 additions & 2 deletions game/source/rasterizer/rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,11 @@ void __cdecl c_rasterizer::set_color_write_enable(long render_state, long render
//g_device->SetRenderState(x_last_render_state_types[render_state], render_state_value);
}

bool __cdecl c_rasterizer::surface_valid(e_surface surface)
{
return INVOKE(0x00A490E0, c_rasterizer::surface_valid, surface);
}

bool __cdecl c_rasterizer::set_compiled_pixel_shader(c_rasterizer_compiled_pixel_shader const* compiled_pixel_shader, e_entry_point entry_point)
{
return INVOKE(0x00A23220, c_rasterizer::set_compiled_pixel_shader, compiled_pixel_shader, entry_point);
Expand Down Expand Up @@ -1523,9 +1528,10 @@ void __cdecl c_rasterizer::draw_vertices(c_rasterizer_index_buffer::e_primitive_
INVOKE(0x00A283B0, c_rasterizer::draw_vertices, primitive_type, start_vertex, primitive_count);
}

void __cdecl c_rasterizer::resolve_entire_surface(e_surface surface, long a2)
// nullsub
void __cdecl c_rasterizer::resolve_entire_surface(e_surface surface, long a2, short_rectangle2d* a3, short a4, short a5)
{
INVOKE(0x00A48C50, c_rasterizer::resolve_entire_surface, surface, a2);
//INVOKE(0x00A48C50, c_rasterizer::resolve_entire_surface, surface, a2, a3, a4, a5);
}

void __cdecl c_rasterizer::set_depth_stencil_surface(e_surface surface)
Expand All @@ -1538,6 +1544,11 @@ void __cdecl c_rasterizer::set_render_target(long render_target_index, e_surface
INVOKE(0x00A48E40, c_rasterizer::set_render_target, render_target_index, surface, render_state);
}

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

void __cdecl c_rasterizer::set_viewport(short_rectangle2d const& viewport, real min_z, real max_z)
{
//INVOKE(0x00A49010, c_rasterizer::set_viewport, viewport, z_min, z_max);
Expand Down
4 changes: 3 additions & 1 deletion game/source/rasterizer/rasterizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ struct c_rasterizer
static void __cdecl set_alpha_blend_mode(e_alpha_blend_mode);
static void __cdecl set_alpha_blend_mode_custom_device_no_cache(IDirect3DDevice9Ex*, e_alpha_blend_mode);
static void __cdecl set_color_write_enable(long, long);
static bool __cdecl surface_valid(e_surface surface);
static bool __cdecl set_compiled_pixel_shader(c_rasterizer_compiled_pixel_shader const*, e_entry_point);
static bool __cdecl set_compiled_vertex_shader(c_rasterizer_compiled_vertex_shader const*, e_vertex_type, e_transfer_vector_vertex_types, e_entry_point);
static void __cdecl set_cull_mode(e_cull_mode);
Expand Down Expand Up @@ -355,9 +356,10 @@ struct c_rasterizer
static void __cdecl draw_primitive_up(c_rasterizer_index_buffer::e_primitive_type primitive_type, dword primitive_count, void const* stream_data, dword stride);
static void __cdecl draw_vertices(c_rasterizer_index_buffer::e_primitive_type primitive_type, long start_vertex, long primitive_count);

static void __cdecl resolve_entire_surface(e_surface surface, long a2);
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_viewport(short_rectangle2d const& viewport, real min_z, real max_z);
static void __cdecl wait_for_gpu_idle();

Expand Down
9 changes: 9 additions & 0 deletions game/source/rasterizer/rasterizer_occlusion_queries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "rasterizer/rasterizer_occlusion_queries.hpp"

#include "cseries/cseries.hpp"

void __cdecl rasterizer_occlusions_retrieve(long a1)
{
INVOKE(0x00A756D0, rasterizer_occlusions_retrieve, a1);
}

4 changes: 4 additions & 0 deletions game/source/rasterizer/rasterizer_occlusion_queries.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

extern void __cdecl rasterizer_occlusions_retrieve(long a1);

63 changes: 56 additions & 7 deletions game/source/render/camera_fx_settings.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "cseries/cseries.hpp"
#include "tag_files/tag_groups.hpp"

struct s_scripted_exposure
{
Expand All @@ -14,9 +15,58 @@ struct s_scripted_exposure
};
static_assert(sizeof(s_scripted_exposure) == 0x34);

struct s_ssao_parameter
{
// SSAO
// SSAO parameters

dword_flags flags;

real intensity;
real radius;
real sample_z_threshold;
};
static_assert(sizeof(s_ssao_parameter) == 0x10);

struct s_color_grading_parameter
{
// COLOR GRADING
// Color grading parameters

dword_flags flags;

real blend_time;

s_tag_block curves_editor;
s_tag_block brightness_contrast;
s_tag_block hue_saturation_lightness_vibrance;
s_tag_block colorize_effect;
s_tag_block selective_color;
s_tag_block color_balance;
};
static_assert(sizeof(s_color_grading_parameter) == 0x50);

struct s_lightshafts
{
// LIGHTSHAFTS
// Lightshafts parameters

dword_flags flags;

real pitch; // [0...90]
real heading; // [0...360]
real_rgb_color tint;
real depth_clamp;
real intensity_clamp; // [0...1]
real falloff_radius; // [0...2]
real intensity; // [0...50]
real blur_radius; // [0...20]
};
static_assert(sizeof(s_lightshafts) == 0x2C);

struct c_camera_fx_settings
{
byte __data[0x170];
byte __data[0x164];

//struct exposure;
//struct auto_exposure_sensitivity;
Expand All @@ -33,16 +83,15 @@ struct c_camera_fx_settings
//struct bling_count;
//struct self_illum_preferred;
//struct self_illum_scale;
//struct ssao;
//struct color_grading;
//struct lightshafts;
s_ssao_parameter ssao;
s_color_grading_parameter color_grading;
s_lightshafts lightshafts;
};
static_assert(sizeof(c_camera_fx_settings) == 0x170);
static_assert(sizeof(c_camera_fx_settings) == 0x1F0);

struct c_camera_fx_values
{
c_camera_fx_settings m_settings;
byte __data[0x80];
byte __data[0x1F0];
};
static_assert(sizeof(c_camera_fx_values) == 0x1F0);

Expand Down
5 changes: 2 additions & 3 deletions game/source/render/render_game_state.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "render/camera_fx_settings.hpp"
#include "cseries/cseries.hpp"

struct s_render_game_state
{
Expand All @@ -12,8 +12,7 @@ struct s_render_game_state

struct s_player_window
{
c_camera_fx_settings camera_fx_settings;
c_camera_fx_values camera_fx_values;
byte __data[0x360];
};
static_assert(sizeof(s_player_window) == 0x360);

Expand Down
9 changes: 9 additions & 0 deletions game/source/render/render_lens_flares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

#include "cseries/cseries.hpp"

//.text:00A5A840 ; void __cdecl lens_flares_garbage_collect()

void __cdecl lens_flares_initialize()
{
INVOKE(0x00A5A8E0, lens_flares_initialize);
}

//.text:00A5A920 ;

void __cdecl lens_flares_render(long a1)
{
INVOKE(0x00A5A960, lens_flares_render, a1);
}

1 change: 1 addition & 0 deletions game/source/render/render_lens_flares.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

extern void __cdecl lens_flares_initialize();
extern void __cdecl lens_flares_render(long a1);

7 changes: 7 additions & 0 deletions game/source/render/render_lights.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#include "render/render_lights.hpp"

#include "render/views/render_view.hpp"

REFERENCE_DECLARE(0x05115B3C, bool, render_default_lighting);

void c_lights_view::submit_simple_light_draw_list_to_shader() const
{
INVOKE_CLASS_MEMBER(0x00A3BF70, c_lights_view, submit_simple_light_draw_list_to_shader);
}

23 changes: 23 additions & 0 deletions game/source/render/render_transparents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,26 @@

REFERENCE_DECLARE(0x05216204, short, render_debug_transparent_sort_method);

//.text:00A73580 ; public: static void __cdecl c_transparency_renderer::pop_marker()
//.text:00A735D0 ; public: static void __cdecl c_transparency_renderer::push_marker()
//.text:00A73620 ;

void __cdecl c_transparency_renderer::render(bool a1)
{
INVOKE(0x00A73640, c_transparency_renderer::render, a1);
}

//.text:00A736E0 ; public: static void __cdecl c_transparency_renderer::reset()

void __cdecl c_transparency_renderer::set_active_camo_bounds(short_rectangle2d const* rect_a, short_rectangle2d const* rect_b)
{
INVOKE(0x00A73710, c_transparency_renderer::set_active_camo_bounds, rect_a, rect_b);
}

//.text:00A73770 ; public: static void __cdecl c_transparency_renderer::resolve_framebuffer_for_active_camo()

void __cdecl c_transparency_renderer::sort()
{
INVOKE(0x00A73880, c_transparency_renderer::sort);
}

9 changes: 9 additions & 0 deletions game/source/render/render_transparents.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#pragma once

#include "cseries/cseries.hpp"

struct c_transparency_renderer
{
static void __cdecl render(bool a1);
static void __cdecl set_active_camo_bounds(short_rectangle2d const* rect_a, short_rectangle2d const* rect_b);
static void __cdecl sort();
};

extern short& render_debug_transparent_sort_method;

16 changes: 11 additions & 5 deletions game/source/render/screen_postprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,33 @@ REFERENCE_DECLARE(0x01917D50, long, g_ssao_enable);
decltype(c_screen_postprocess::postprocess_player_view)* screen_postprocess_postprocess_player_view = c_screen_postprocess::postprocess_player_view;
HOOK_DECLARE_CALL(0x00A39F4E, screen_postprocess_postprocess_player_view);
HOOK_DECLARE_CALL(0x00A3A171, sub_A62D70);
HOOK_DECLARE_CALL(0x00A61BBD, sub_A62720);

HOOK_DECLARE_CLASS(0x00A60460, c_screen_postprocess, copy);
HOOK_DECLARE_CLASS(0x00A601E0, c_screen_postprocess, blit);
HOOK_DECLARE_CLASS(0x00A60D60, c_screen_postprocess, gaussian_blur);

void __cdecl sub_A62D70(c_camera_fx_values* fx_values, render_projection* projection, render_camera* camera)
void __cdecl sub_A62720(s_lightshafts* lightshafts, render_projection* projection, render_camera* camera, c_rasterizer::e_surface surface_a, c_rasterizer::e_surface surface_b)
{
c_d3d_pix_event _lightshafts(g_rasterizer_profile_pix_colors[1], L"lightshafts");

INVOKE(0x00A62720, sub_A62720, lightshafts, projection, camera, surface_a, surface_b);
}

void __cdecl sub_A62D70(c_camera_fx_settings* fx_settings, render_projection* projection, render_camera* camera)
{
if (players_get_active_and_in_game_count(true) > 1)
return;

REFERENCE_DECLARE(offset_pointer(fx_values->m_settings.__data, 0x164), dword_flags, ssao_flags);

bool ssao_enable = TEST_BIT(ssao_flags, 1);
bool ssao_enable = TEST_BIT(fx_settings->ssao.flags, 1);
if (g_ssao_enable != NONE)
ssao_enable = g_ssao_enable == 1;

if (ssao_enable && global_preferences_get_postprocessing_quality())
{
c_d3d_pix_event _ssao(g_rasterizer_profile_pix_colors[1], L"ssao");

INVOKE(0x00A62D70, sub_A62D70, fx_values, projection, camera);
INVOKE(0x00A62D70, sub_A62D70, fx_settings, projection, camera);
}
}

Expand Down
16 changes: 15 additions & 1 deletion game/source/render/screen_postprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum e_splitscreen_res;
enum e_output_user_index;

struct c_camera_fx_values;
struct c_camera_fx_settings;
struct render_projection;
struct render_camera;
struct s_screen_effect_settings;
Expand Down Expand Up @@ -54,7 +55,20 @@ struct c_screen_postprocess
c_rasterizer::e_surface surface);

static void __cdecl setup_rasterizer_for_postprocess(bool a1);

struct s_settings
{
bool __unknown0;
byte __data1[0x37];
};
static_assert(sizeof(s_settings) == 0x38);

static c_screen_postprocess::s_settings const* const& x_settings;

};

extern void __cdecl sub_A62D70(c_camera_fx_values* fx_values, render_projection* projection, render_camera* camera);
struct s_lightshafts;

extern void __cdecl sub_A62720(s_lightshafts* lightshafts, render_projection* projection, render_camera* camera, c_rasterizer::e_surface surface_a, c_rasterizer::e_surface surface_b);
extern void __cdecl sub_A62D70(c_camera_fx_settings* fx_settings, render_projection* projection, render_camera* camera);

Loading

0 comments on commit 61a185d

Please sign in to comment.