common/types: use stdint typedefs everywhere instead of custom u32/s32 aliases

The codebase carried custom aliases in src/common/types.h:

  using s8  = int8_t;
  using u8  = uint8_t;
  using s16 = int16_t;
  using u16 = uint16_t;
  using s32 = int32_t;
  using u32 = uint32_t;
  using s64 = int64_t;
  using u64 = uint64_t;

These are pure aliases - they alias the C99/C++11 fixed-width
exact types from <cstdint> verbatim - and the short form was
used throughout in ~8,400 places. The short form is a
convention common in emulator/game code, but it conflicts with
the convention used by every other piece of code anyone on this
project ever touches (kernel, libretro frontends and other
cores, stdlib code, etc.), and the savings are five characters
per use.

Mechanical rename across src/:

  s8 -> int8_t
  u8 -> uint8_t
  s16 -> int16_t
  u16 -> uint16_t
  s32 -> int32_t
  u32 -> uint32_t
  s64 -> int64_t
  u64 -> uint64_t

Word-boundary substitution via \b{name}\b. Verified no false
positives:
  - No string literal contains "u32" etc. (single-line scan
    of every .cpp/.h/.inl in src/).
  - No identifier contains the alias as a substring; \b prevents
    matching inside foo_u32 / u32_bar style names but a separate
    check confirmed there are no such identifiers in src/
    anyway.

The dep/ directory is left untouched - some third-party code
there (zstd, dr_libs, libchdr) has its own unrelated "u32"
struct fields and types that are local to those compilation units.

Aliases removed from src/common/types.h. The header keeps
<cstdint> (the BCD helpers there still use uint8_t) and stays
the same shape it was post-types-cleanup.

Build: Makefile.libretro platform=unix - clean.
Codegen identical: the produced swanstation_libretro.so is
byte-for-byte the same as the pre-rename build, MD5
453480b212f78f0e0cf56fc893972b24 in both cases. This is
expected: u32 and uint32_t are the same type to the compiler;
the rename is purely lexical.

retro_* exports: 25 (unchanged).

210 files changed, +7926 -7935 (the -9 net delta is the eight
'using' lines removed from types.h plus blank-line cleanup
around them).
This commit is contained in:
LibretroAdmin 2026-05-14 13:03:30 +00:00 • committed by U-DESKTOP-SPFP6AQ\twistedtechre
commit 7537ee7a27
210 changed files with 7926 additions and 7935 deletions

View file

@ -130,8 +130,8 @@ bool GPU_HW::DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool u
void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
{
const u32 resolution_scale = CalculateResolutionScale();
const u32 multisamples = std::min(m_max_multisamples, g_settings.gpu_multisamples);
const uint32_t resolution_scale = CalculateResolutionScale();
const uint32_t multisamples = std::min(m_max_multisamples, g_settings.gpu_multisamples);
const bool per_sample_shading = g_settings.gpu_per_sample_shading && m_supports_per_sample_shading;
const GPUDownsampleMode downsample_mode = GetDownsampleMode(resolution_scale);
const bool use_uv_limits = ShouldUseUVLimits();
@ -174,7 +174,7 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
UpdateSoftwareRenderer(true);
}
static u32 PreviousPow2(u32 value)
static uint32_t PreviousPow2(uint32_t value)
{
value |= (value >> 1);
value |= (value >> 2);
@ -184,22 +184,22 @@ static u32 PreviousPow2(u32 value)
return value - (value >> 1);
}
u32 GPU_HW::CalculateResolutionScale() const
uint32_t GPU_HW::CalculateResolutionScale() const
{
u32 scale;
uint32_t scale;
if (g_settings.gpu_resolution_scale != 0)
scale = std::clamp<u32>(g_settings.gpu_resolution_scale, 1, m_max_resolution_scale);
scale = std::clamp<uint32_t>(g_settings.gpu_resolution_scale, 1, m_max_resolution_scale);
else
{
// Auto scaling. When the system is starting and all borders crop is enabled, the registers are zero, and
// display_height therefore is also zero. Use the default size from the region in this case.
const s32 height = (m_crtc_state.display_height != 0) ?
static_cast<s32>(m_crtc_state.display_height) :
const int32_t height = (m_crtc_state.display_height != 0) ?
static_cast<int32_t>(m_crtc_state.display_height) :
(m_console_is_pal ? (PAL_VERTICAL_ACTIVE_END - PAL_VERTICAL_ACTIVE_START) :
(NTSC_VERTICAL_ACTIVE_END - NTSC_VERTICAL_ACTIVE_START));
const s32 preferred_scale =
static_cast<s32>(std::ceil(static_cast<float>(m_host_display->GetWindowHeight()) / height));
scale = static_cast<u32>(std::clamp<s32>(preferred_scale, 1, m_max_resolution_scale));
const int32_t preferred_scale =
static_cast<int32_t>(std::ceil(static_cast<float>(m_host_display->GetWindowHeight()) / height));
scale = static_cast<uint32_t>(std::clamp<int32_t>(preferred_scale, 1, m_max_resolution_scale));
}
if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && m_supports_adaptive_downsampling && scale > 1 &&
!(IS_POW2(scale)))
@ -207,7 +207,7 @@ u32 GPU_HW::CalculateResolutionScale() const
return scale;
}
GPUDownsampleMode GPU_HW::GetDownsampleMode(u32 resolution_scale) const
GPUDownsampleMode GPU_HW::GetDownsampleMode(uint32_t resolution_scale) const
{
if (resolution_scale == 1)
return GPUDownsampleMode::Disabled;
@ -259,7 +259,7 @@ void GPU_HW::HandleFlippedQuadTextureCoordinates(BatchVertex* vertices)
const float area = bcx * cay - bcy * cax;
// Detect and reject any triangles with 0 size texture area
const s32 texArea = (vertices[1].u - vertices[0].u) * (vertices[2].v - vertices[0].v) -
const int32_t texArea = (vertices[1].u - vertices[0].u) * (vertices[2].v - vertices[0].v) -
(vertices[2].u - vertices[0].u) * (vertices[1].v - vertices[0].v);
// Leverage PGXP to further avoid 3D polygons that just happen to align this way after projection
@ -313,15 +313,15 @@ void GPU_HW::HandleFlippedQuadTextureCoordinates(BatchVertex* vertices)
}
}
void GPU_HW::ComputePolygonUVLimits(BatchVertex* vertices, u32 num_vertices)
void GPU_HW::ComputePolygonUVLimits(BatchVertex* vertices, uint32_t num_vertices)
{
u16 min_u = vertices[0].u, max_u = vertices[0].u, min_v = vertices[0].v, max_v = vertices[0].v;
for (u32 i = 1; i < num_vertices; i++)
uint16_t min_u = vertices[0].u, max_u = vertices[0].u, min_v = vertices[0].v, max_v = vertices[0].v;
for (uint32_t i = 1; i < num_vertices; i++)
{
min_u = std::min<u16>(min_u, vertices[i].u);
max_u = std::max<u16>(max_u, vertices[i].u);
min_v = std::min<u16>(min_v, vertices[i].v);
max_v = std::max<u16>(max_v, vertices[i].v);
min_u = std::min<uint16_t>(min_u, vertices[i].u);
max_u = std::max<uint16_t>(max_u, vertices[i].u);
min_v = std::min<uint16_t>(min_v, vertices[i].v);
max_v = std::max<uint16_t>(max_v, vertices[i].v);
}
if (min_u != max_u)
@ -329,7 +329,7 @@ void GPU_HW::ComputePolygonUVLimits(BatchVertex* vertices, u32 num_vertices)
if (min_v != max_v)
max_v--;
for (u32 i = 0; i < num_vertices; i++)
for (uint32_t i = 0; i < num_vertices; i++)
vertices[i].uv_limits = BatchVertex::PackUVLimits(min_u, max_u, min_v, max_v);
}
@ -343,7 +343,7 @@ void GPU_HW::SetBatchDepthBuffer(bool enabled)
m_batch.use_depth_buffer = enabled;
}
void GPU_HW::CheckForDepthClear(const BatchVertex* vertices, u32 num_vertices)
void GPU_HW::CheckForDepthClear(const BatchVertex* vertices, uint32_t num_vertices)
{
float average_z;
if (num_vertices == 3)
@ -365,10 +365,10 @@ void GPU_HW::CheckForDepthClear(const BatchVertex* vertices, u32 num_vertices)
m_last_depth_z = average_z;
}
u32 GPU_HW::GetAdaptiveDownsamplingMipLevels() const
uint32_t GPU_HW::GetAdaptiveDownsamplingMipLevels() const
{
u32 levels = 0;
u32 current_width = VRAM_WIDTH * m_resolution_scale;
uint32_t levels = 0;
uint32_t current_width = VRAM_WIDTH * m_resolution_scale;
while (current_width >= VRAM_WIDTH)
{
levels++;
@ -378,8 +378,8 @@ u32 GPU_HW::GetAdaptiveDownsamplingMipLevels() const
return levels;
}
GPU_HW::SmoothingUBOData GPU_HW::GetSmoothingUBO(u32 level, u32 left, u32 top, u32 width, u32 height, u32 tex_width,
u32 tex_height) const
GPU_HW::SmoothingUBOData GPU_HW::GetSmoothingUBO(uint32_t level, uint32_t left, uint32_t top, uint32_t width, uint32_t height, uint32_t tex_width,
uint32_t tex_height) const
{
const float rcp_width = 1.0f / static_cast<float>(tex_width >> level);
const float rcp_height = 1.0f / static_cast<float>(tex_height >> level);
@ -395,7 +395,7 @@ GPU_HW::SmoothingUBOData GPU_HW::GetSmoothingUBO(u32 level, u32 left, u32 top, u
return data;
}
void GPU_HW::DrawLine(float x0, float y0, u32 col0, float x1, float y1, u32 col1, float depth)
void GPU_HW::DrawLine(float x0, float y0, uint32_t col0, float x1, float y1, uint32_t col1, float depth)
{
const float dx = x1 - x0;
const float dy = y1 - y0;
@ -490,31 +490,31 @@ void GPU_HW::LoadVertices()
m_current_depth++;
const GPURenderCommand rc{m_render_command.bits};
const u32 texpage = static_cast<u32>(m_draw_mode.mode_reg.bits) | (static_cast<u32>(m_draw_mode.palette_reg) << 16);
const uint32_t texpage = static_cast<uint32_t>(m_draw_mode.mode_reg.bits) | (static_cast<uint32_t>(m_draw_mode.palette_reg) << 16);
const float depth = GetCurrentNormalizedVertexDepth();
switch (rc.primitive)
{
case GPUPrimitive::Polygon:
{
u16 native_texcoords[4];
const u32 first_color = rc.color_for_first_vertex;
uint16_t native_texcoords[4];
const uint32_t first_color = rc.color_for_first_vertex;
const bool shaded = rc.shading_enable;
const bool textured = rc.texture_enable;
const bool pgxp = g_settings.gpu_pgxp_enable;
const u32 num_vertices = rc.quad_polygon ? 4 : 3;
const uint32_t num_vertices = rc.quad_polygon ? 4 : 3;
std::array<BatchVertex, 4> vertices;
std::array<std::array<s32, 2>, 4> native_vertex_positions;
std::array<std::array<int32_t, 2>, 4> native_vertex_positions;
bool valid_w = g_settings.gpu_pgxp_texture_correction;
for (u32 i = 0; i < num_vertices; i++)
for (uint32_t i = 0; i < num_vertices; i++)
{
const u32 color = (shaded && i > 0) ? (FifoPop() & UINT32_C(0x00FFFFFF)) : first_color;
const u64 maddr_and_pos = m_fifo.Pop();
const GPUVertexPosition vp{static_cast<u32>(maddr_and_pos)};
const u16 texcoord = textured ? static_cast<u16>(FifoPop()) : 0;
const s32 native_x = m_drawing_offset.x + vp.x;
const s32 native_y = m_drawing_offset.y + vp.y;
const uint32_t color = (shaded && i > 0) ? (FifoPop() & UINT32_C(0x00FFFFFF)) : first_color;
const uint64_t maddr_and_pos = m_fifo.Pop();
const GPUVertexPosition vp{static_cast<uint32_t>(maddr_and_pos)};
const uint16_t texcoord = textured ? static_cast<uint16_t>(FifoPop()) : 0;
const int32_t native_x = m_drawing_offset.x + vp.x;
const int32_t native_y = m_drawing_offset.y + vp.y;
native_vertex_positions[i][0] = native_x;
native_vertex_positions[i][1] = native_y;
native_texcoords[i] = texcoord;
@ -524,7 +524,7 @@ void GPU_HW::LoadVertices()
if (pgxp)
{
valid_w &=
PGXP::GetPreciseVertex(static_cast<u32>(maddr_and_pos >> 32), vp.bits, native_x, native_y, m_drawing_offset.x,
PGXP::GetPreciseVertex(static_cast<uint32_t>(maddr_and_pos >> 32), vp.bits, native_x, native_y, m_drawing_offset.x,
m_drawing_offset.y, &vertices[i].x, &vertices[i].y, &vertices[i].w);
}
}
@ -559,21 +559,21 @@ void GPU_HW::LoadVertices()
// Cull polygons which are too large.
const auto [min_x_12, max_x_12] = MinMax(native_vertex_positions[1][0], native_vertex_positions[2][0]);
const auto [min_y_12, max_y_12] = MinMax(native_vertex_positions[1][1], native_vertex_positions[2][1]);
const s32 min_x = std::min(min_x_12, native_vertex_positions[0][0]);
const s32 max_x = std::max(max_x_12, native_vertex_positions[0][0]);
const s32 min_y = std::min(min_y_12, native_vertex_positions[0][1]);
const s32 max_y = std::max(max_y_12, native_vertex_positions[0][1]);
const int32_t min_x = std::min(min_x_12, native_vertex_positions[0][0]);
const int32_t max_x = std::max(max_x_12, native_vertex_positions[0][0]);
const int32_t min_y = std::min(min_y_12, native_vertex_positions[0][1]);
const int32_t max_y = std::max(max_y_12, native_vertex_positions[0][1]);
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
{
}
else
{
const u32 clip_left = static_cast<u32>(std::clamp<s32>(min_x, m_drawing_area.left, m_drawing_area.right));
const u32 clip_right = static_cast<u32>(std::clamp<s32>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const u32 clip_top = static_cast<u32>(std::clamp<s32>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const u32 clip_bottom =
static_cast<u32>(std::clamp<s32>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
const uint32_t clip_left = static_cast<uint32_t>(std::clamp<int32_t>(min_x, m_drawing_area.left, m_drawing_area.right));
const uint32_t clip_right = static_cast<uint32_t>(std::clamp<int32_t>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const uint32_t clip_top = static_cast<uint32_t>(std::clamp<int32_t>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const uint32_t clip_bottom =
static_cast<uint32_t>(std::clamp<int32_t>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom);
AddDrawTriangleTicks(native_vertex_positions[0][0], native_vertex_positions[0][1],
@ -588,10 +588,10 @@ void GPU_HW::LoadVertices()
// quads
if (rc.quad_polygon)
{
const s32 min_x_123 = std::min(min_x_12, native_vertex_positions[3][0]);
const s32 max_x_123 = std::max(max_x_12, native_vertex_positions[3][0]);
const s32 min_y_123 = std::min(min_y_12, native_vertex_positions[3][1]);
const s32 max_y_123 = std::max(max_y_12, native_vertex_positions[3][1]);
const int32_t min_x_123 = std::min(min_x_12, native_vertex_positions[3][0]);
const int32_t max_x_123 = std::max(max_x_12, native_vertex_positions[3][0]);
const int32_t min_y_123 = std::min(min_y_12, native_vertex_positions[3][1]);
const int32_t max_y_123 = std::max(max_y_12, native_vertex_positions[3][1]);
// Cull polygons which are too large.
if ((max_x_123 - min_x_123) >= MAX_PRIMITIVE_WIDTH || (max_y_123 - min_y_123) >= MAX_PRIMITIVE_HEIGHT)
@ -599,12 +599,12 @@ void GPU_HW::LoadVertices()
}
else
{
const u32 clip_left = static_cast<u32>(std::clamp<s32>(min_x_123, m_drawing_area.left, m_drawing_area.right));
const u32 clip_right =
static_cast<u32>(std::clamp<s32>(max_x_123, m_drawing_area.left, m_drawing_area.right)) + 1u;
const u32 clip_top = static_cast<u32>(std::clamp<s32>(min_y_123, m_drawing_area.top, m_drawing_area.bottom));
const u32 clip_bottom =
static_cast<u32>(std::clamp<s32>(max_y_123, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
const uint32_t clip_left = static_cast<uint32_t>(std::clamp<int32_t>(min_x_123, m_drawing_area.left, m_drawing_area.right));
const uint32_t clip_right =
static_cast<uint32_t>(std::clamp<int32_t>(max_x_123, m_drawing_area.left, m_drawing_area.right)) + 1u;
const uint32_t clip_top = static_cast<uint32_t>(std::clamp<int32_t>(min_y_123, m_drawing_area.top, m_drawing_area.bottom));
const uint32_t clip_bottom =
static_cast<uint32_t>(std::clamp<int32_t>(max_y_123, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom);
AddDrawTriangleTicks(native_vertex_positions[2][0], native_vertex_positions[2][1],
@ -623,7 +623,7 @@ void GPU_HW::LoadVertices()
GPUBackendDrawPolygonCommand* cmd = m_sw_renderer->NewDrawPolygonCommand(num_vertices);
FillDrawCommand(cmd, rc);
for (u32 i = 0; i < num_vertices; i++)
for (uint32_t i = 0; i < num_vertices; i++)
{
GPUBackendDrawPolygonCommand::Vertex* vert = &cmd->vertices[i];
vert->x = native_vertex_positions[i][0];
@ -639,16 +639,16 @@ void GPU_HW::LoadVertices()
case GPUPrimitive::Rectangle:
{
const u32 color = rc.color_for_first_vertex;
const uint32_t color = rc.color_for_first_vertex;
const GPUVertexPosition vp{FifoPop()};
const s32 pos_x = TruncateGPUVertexPosition(m_drawing_offset.x + vp.x);
const s32 pos_y = TruncateGPUVertexPosition(m_drawing_offset.y + vp.y);
const int32_t pos_x = TruncateGPUVertexPosition(m_drawing_offset.x + vp.x);
const int32_t pos_y = TruncateGPUVertexPosition(m_drawing_offset.y + vp.y);
const auto [texcoord_x, texcoord_y] = UnpackTexcoord(rc.texture_enable ? static_cast<u16>(FifoPop()) : 0);
u16 orig_tex_left = static_cast<u16>(texcoord_x);
u16 orig_tex_top = static_cast<u16>(texcoord_y);
s32 rectangle_width;
s32 rectangle_height;
const auto [texcoord_x, texcoord_y] = UnpackTexcoord(rc.texture_enable ? static_cast<uint16_t>(FifoPop()) : 0);
uint16_t orig_tex_left = static_cast<uint16_t>(texcoord_x);
uint16_t orig_tex_top = static_cast<uint16_t>(texcoord_y);
int32_t rectangle_width;
int32_t rectangle_height;
switch (rc.rectangle_size)
{
case GPUDrawRectangleSize::R1x1:
@ -665,9 +665,9 @@ void GPU_HW::LoadVertices()
break;
default:
{
const u32 width_and_height = FifoPop();
rectangle_width = static_cast<s32>(width_and_height & VRAM_WIDTH_MASK);
rectangle_height = static_cast<s32>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
const uint32_t width_and_height = FifoPop();
rectangle_width = static_cast<int32_t>(width_and_height & VRAM_WIDTH_MASK);
rectangle_height = static_cast<int32_t>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
if (rectangle_width >= MAX_PRIMITIVE_WIDTH || rectangle_height >= MAX_PRIMITIVE_HEIGHT)
return;
@ -683,22 +683,22 @@ void GPU_HW::LoadVertices()
SetBatchDepthBuffer(false);
// Split the rectangle into multiple quads if it's greater than 256x256, as the texture page should repeat.
u16 tex_top = orig_tex_top;
for (s32 y_offset = 0; y_offset < rectangle_height;)
uint16_t tex_top = orig_tex_top;
for (int32_t y_offset = 0; y_offset < rectangle_height;)
{
const s32 quad_height = std::min<s32>(rectangle_height - y_offset, TEXTURE_PAGE_WIDTH - tex_top);
const int32_t quad_height = std::min<int32_t>(rectangle_height - y_offset, TEXTURE_PAGE_WIDTH - tex_top);
const float quad_start_y = static_cast<float>(pos_y + y_offset);
const float quad_end_y = quad_start_y + static_cast<float>(quad_height);
const u16 tex_bottom = tex_top + static_cast<u16>(quad_height);
const uint16_t tex_bottom = tex_top + static_cast<uint16_t>(quad_height);
u16 tex_left = orig_tex_left;
for (s32 x_offset = 0; x_offset < rectangle_width;)
uint16_t tex_left = orig_tex_left;
for (int32_t x_offset = 0; x_offset < rectangle_width;)
{
const s32 quad_width = std::min<s32>(rectangle_width - x_offset, TEXTURE_PAGE_HEIGHT - tex_left);
const int32_t quad_width = std::min<int32_t>(rectangle_width - x_offset, TEXTURE_PAGE_HEIGHT - tex_left);
const float quad_start_x = static_cast<float>(pos_x + x_offset);
const float quad_end_x = quad_start_x + static_cast<float>(quad_width);
const u16 tex_right = tex_left + static_cast<u16>(quad_width);
const u32 uv_limits = BatchVertex::PackUVLimits(tex_left, tex_right - 1, tex_top, tex_bottom - 1);
const uint16_t tex_right = tex_left + static_cast<uint16_t>(quad_width);
const uint32_t uv_limits = BatchVertex::PackUVLimits(tex_left, tex_right - 1, tex_top, tex_bottom - 1);
AddNewVertex(quad_start_x, quad_start_y, depth, 1.0f, color, texpage, tex_left, tex_top, uv_limits);
AddNewVertex(quad_end_x, quad_start_y, depth, 1.0f, color, texpage, tex_right, tex_top, uv_limits);
@ -716,12 +716,12 @@ void GPU_HW::LoadVertices()
tex_top = 0;
}
const u32 clip_left = static_cast<u32>(std::clamp<s32>(pos_x, m_drawing_area.left, m_drawing_area.right));
const u32 clip_right =
static_cast<u32>(std::clamp<s32>(pos_x + rectangle_width, m_drawing_area.left, m_drawing_area.right)) + 1u;
const u32 clip_top = static_cast<u32>(std::clamp<s32>(pos_y, m_drawing_area.top, m_drawing_area.bottom));
const u32 clip_bottom =
static_cast<u32>(std::clamp<s32>(pos_y + rectangle_height, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
const uint32_t clip_left = static_cast<uint32_t>(std::clamp<int32_t>(pos_x, m_drawing_area.left, m_drawing_area.right));
const uint32_t clip_right =
static_cast<uint32_t>(std::clamp<int32_t>(pos_x + rectangle_width, m_drawing_area.left, m_drawing_area.right)) + 1u;
const uint32_t clip_top = static_cast<uint32_t>(std::clamp<int32_t>(pos_y, m_drawing_area.top, m_drawing_area.bottom));
const uint32_t clip_bottom =
static_cast<uint32_t>(std::clamp<int32_t>(pos_y + rectangle_height, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom);
AddDrawRectangleTicks(clip_right - clip_left, clip_bottom - clip_top, rc.texture_enable, rc.transparency_enable);
@ -733,9 +733,9 @@ void GPU_HW::LoadVertices()
cmd->color = color;
cmd->x = pos_x;
cmd->y = pos_y;
cmd->width = static_cast<u16>(rectangle_width);
cmd->height = static_cast<u16>(rectangle_height);
cmd->texcoord = (static_cast<u16>(texcoord_y) << 8) | static_cast<u16>(texcoord_x);
cmd->width = static_cast<uint16_t>(rectangle_width);
cmd->height = static_cast<uint16_t>(rectangle_height);
cmd->texcoord = (static_cast<uint16_t>(texcoord_y) << 8) | static_cast<uint16_t>(texcoord_x);
m_sw_renderer->PushCommand(cmd);
}
}
@ -748,7 +748,7 @@ void GPU_HW::LoadVertices()
if (!rc.polyline)
{
u32 start_color, end_color;
uint32_t start_color, end_color;
GPUVertexPosition start_pos, end_pos;
if (rc.shading_enable)
{
@ -767,20 +767,20 @@ void GPU_HW::LoadVertices()
if (!IsDrawingAreaIsValid())
return;
s32 start_x = start_pos.x + m_drawing_offset.x;
s32 start_y = start_pos.y + m_drawing_offset.y;
s32 end_x = end_pos.x + m_drawing_offset.x;
s32 end_y = end_pos.y + m_drawing_offset.y;
int32_t start_x = start_pos.x + m_drawing_offset.x;
int32_t start_y = start_pos.y + m_drawing_offset.y;
int32_t end_x = end_pos.x + m_drawing_offset.x;
int32_t end_y = end_pos.y + m_drawing_offset.y;
const auto [min_x, max_x] = MinMax(start_x, end_x);
const auto [min_y, max_y] = MinMax(start_y, end_y);
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
return;
const u32 clip_left = static_cast<u32>(std::clamp<s32>(min_x, m_drawing_area.left, m_drawing_area.right));
const u32 clip_right = static_cast<u32>(std::clamp<s32>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const u32 clip_top = static_cast<u32>(std::clamp<s32>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const u32 clip_bottom =
static_cast<u32>(std::clamp<s32>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
const uint32_t clip_left = static_cast<uint32_t>(std::clamp<int32_t>(min_x, m_drawing_area.left, m_drawing_area.right));
const uint32_t clip_right = static_cast<uint32_t>(std::clamp<int32_t>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const uint32_t clip_top = static_cast<uint32_t>(std::clamp<int32_t>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const uint32_t clip_bottom =
static_cast<uint32_t>(std::clamp<int32_t>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom);
AddDrawLineTicks(clip_right - clip_left, clip_bottom - clip_top, rc.shading_enable);
@ -801,18 +801,18 @@ void GPU_HW::LoadVertices()
else
{
// Multiply by two because we don't use line strips.
const u32 num_vertices = GetPolyLineVertexCount();
const uint32_t num_vertices = GetPolyLineVertexCount();
if (!IsDrawingAreaIsValid())
return;
const bool shaded = rc.shading_enable;
u32 buffer_pos = 0;
uint32_t buffer_pos = 0;
const GPUVertexPosition start_vp{m_blit_buffer[buffer_pos++]};
s32 start_x = start_vp.x + m_drawing_offset.x;
s32 start_y = start_vp.y + m_drawing_offset.y;
u32 start_color = rc.color_for_first_vertex;
int32_t start_x = start_vp.x + m_drawing_offset.x;
int32_t start_y = start_vp.y + m_drawing_offset.y;
uint32_t start_color = rc.color_for_first_vertex;
GPUBackendDrawLineCommand* cmd;
if (m_sw_renderer)
@ -826,12 +826,12 @@ void GPU_HW::LoadVertices()
cmd = nullptr;
}
for (u32 i = 1; i < num_vertices; i++)
for (uint32_t i = 1; i < num_vertices; i++)
{
const u32 end_color = shaded ? (m_blit_buffer[buffer_pos++] & UINT32_C(0x00FFFFFF)) : start_color;
const uint32_t end_color = shaded ? (m_blit_buffer[buffer_pos++] & UINT32_C(0x00FFFFFF)) : start_color;
const GPUVertexPosition vp{m_blit_buffer[buffer_pos++]};
const s32 end_x = m_drawing_offset.x + vp.x;
const s32 end_y = m_drawing_offset.y + vp.y;
const int32_t end_x = m_drawing_offset.x + vp.x;
const int32_t end_y = m_drawing_offset.y + vp.y;
const auto [min_x, max_x] = MinMax(start_x, end_x);
const auto [min_y, max_y] = MinMax(start_y, end_y);
@ -840,12 +840,12 @@ void GPU_HW::LoadVertices()
}
else
{
const u32 clip_left = static_cast<u32>(std::clamp<s32>(min_x, m_drawing_area.left, m_drawing_area.right));
const u32 clip_right =
static_cast<u32>(std::clamp<s32>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const u32 clip_top = static_cast<u32>(std::clamp<s32>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const u32 clip_bottom =
static_cast<u32>(std::clamp<s32>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
const uint32_t clip_left = static_cast<uint32_t>(std::clamp<int32_t>(min_x, m_drawing_area.left, m_drawing_area.right));
const uint32_t clip_right =
static_cast<uint32_t>(std::clamp<int32_t>(max_x, m_drawing_area.left, m_drawing_area.right)) + 1u;
const uint32_t clip_top = static_cast<uint32_t>(std::clamp<int32_t>(min_y, m_drawing_area.top, m_drawing_area.bottom));
const uint32_t clip_bottom =
static_cast<uint32_t>(std::clamp<int32_t>(max_y, m_drawing_area.top, m_drawing_area.bottom)) + 1u;
m_vram_dirty_rect.Include(clip_left, clip_right, clip_top, clip_bottom);
AddDrawLineTicks(clip_right - clip_left, clip_bottom - clip_top, rc.shading_enable);
@ -877,12 +877,12 @@ void GPU_HW::LoadVertices()
void GPU_HW::CalcScissorRect(int* left, int* top, int* right, int* bottom)
{
*left = m_drawing_area.left * m_resolution_scale;
*right = std::max<u32>((m_drawing_area.right + 1) * m_resolution_scale, *left + 1);
*right = std::max<uint32_t>((m_drawing_area.right + 1) * m_resolution_scale, *left + 1);
*top = m_drawing_area.top * m_resolution_scale;
*bottom = std::max<u32>((m_drawing_area.bottom + 1) * m_resolution_scale, *top + 1);
*bottom = std::max<uint32_t>((m_drawing_area.bottom + 1) * m_resolution_scale, *top + 1);
}
GPU_HW::VRAMFillUBOData GPU_HW::GetVRAMFillUBOData(u32 x, u32 y, u32 width, u32 height, u32 color) const
GPU_HW::VRAMFillUBOData GPU_HW::GetVRAMFillUBOData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color) const
{
// drop precision unless true colour is enabled
if (!m_true_color)
@ -900,9 +900,9 @@ GPU_HW::VRAMFillUBOData GPU_HW::GetVRAMFillUBOData(u32 x, u32 y, u32 width, u32
return uniforms;
}
Common::Rectangle<u32> GPU_HW::GetVRAMTransferBounds(u32 x, u32 y, u32 width, u32 height) const
Common::Rectangle<uint32_t> GPU_HW::GetVRAMTransferBounds(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const
{
Common::Rectangle<u32> out_rc = Common::Rectangle<u32>::FromExtents(x % VRAM_WIDTH, y % VRAM_HEIGHT, width, height);
Common::Rectangle<uint32_t> out_rc = Common::Rectangle<uint32_t>::FromExtents(x % VRAM_WIDTH, y % VRAM_HEIGHT, width, height);
if (out_rc.right > VRAM_WIDTH)
{
out_rc.left = 0;
@ -916,7 +916,7 @@ Common::Rectangle<u32> GPU_HW::GetVRAMTransferBounds(u32 x, u32 y, u32 width, u3
return out_rc;
}
GPU_HW::VRAMWriteUBOData GPU_HW::GetVRAMWriteUBOData(u32 x, u32 y, u32 width, u32 height, u32 buffer_offset,
GPU_HW::VRAMWriteUBOData GPU_HW::GetVRAMWriteUBOData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t buffer_offset,
bool set_mask, bool check_mask) const
{
const VRAMWriteUBOData uniforms = {
@ -925,18 +925,18 @@ GPU_HW::VRAMWriteUBOData GPU_HW::GetVRAMWriteUBOData(u32 x, u32 y, u32 width, u3
return uniforms;
}
bool GPU_HW::UseVRAMCopyShader(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) const
bool GPU_HW::UseVRAMCopyShader(uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, uint32_t width, uint32_t height) const
{
// masking enabled, oversized, or overlapping
return (m_GPUSTAT.IsMaskingEnabled() || ((src_x % VRAM_WIDTH) + width) > VRAM_WIDTH ||
((src_y % VRAM_HEIGHT) + height) > VRAM_HEIGHT || ((dst_x % VRAM_WIDTH) + width) > VRAM_WIDTH ||
((dst_y % VRAM_HEIGHT) + height) > VRAM_HEIGHT ||
Common::Rectangle<u32>::FromExtents(src_x, src_y, width, height)
.Intersects(Common::Rectangle<u32>::FromExtents(dst_x, dst_y, width, height)));
Common::Rectangle<uint32_t>::FromExtents(src_x, src_y, width, height)
.Intersects(Common::Rectangle<uint32_t>::FromExtents(dst_x, dst_y, width, height)));
}
GPU_HW::VRAMCopyUBOData GPU_HW::GetVRAMCopyUBOData(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width,
u32 height) const
GPU_HW::VRAMCopyUBOData GPU_HW::GetVRAMCopyUBOData(uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, uint32_t width,
uint32_t height) const
{
const VRAMCopyUBOData uniforms = {(src_x % VRAM_WIDTH) * m_resolution_scale,
(src_y % VRAM_HEIGHT) * m_resolution_scale,
@ -952,7 +952,7 @@ GPU_HW::VRAMCopyUBOData GPU_HW::GetVRAMCopyUBOData(u32 src_x, u32 src_y, u32 dst
return uniforms;
}
void GPU_HW::IncludeVRAMDirtyRectangle(const Common::Rectangle<u32>& rect)
void GPU_HW::IncludeVRAMDirtyRectangle(const Common::Rectangle<uint32_t>& rect)
{
m_vram_dirty_rect.Include(rect);
@ -966,7 +966,7 @@ void GPU_HW::IncludeVRAMDirtyRectangle(const Common::Rectangle<u32>& rect)
}
}
void GPU_HW::EnsureVertexBufferSpace(u32 required_vertices)
void GPU_HW::EnsureVertexBufferSpace(uint32_t required_vertices)
{
if (m_batch_current_vertex_ptr)
{
@ -981,7 +981,7 @@ void GPU_HW::EnsureVertexBufferSpace(u32 required_vertices)
void GPU_HW::EnsureVertexBufferSpaceForCurrentCommand()
{
u32 required_vertices;
uint32_t required_vertices;
switch (m_render_command.primitive)
{
case GPUPrimitive::Polygon:
@ -1050,7 +1050,7 @@ void GPU_HW::UpdateSoftwareRenderer(bool copy_vram_from_hw)
{
FlushRender();
ReadVRAM(0, 0, VRAM_WIDTH, VRAM_HEIGHT);
std::memcpy(sw_renderer->GetVRAM(), m_vram_ptr, sizeof(u16) * VRAM_WIDTH * VRAM_HEIGHT);
std::memcpy(sw_renderer->GetVRAM(), m_vram_ptr, sizeof(uint16_t) * VRAM_WIDTH * VRAM_HEIGHT);
// Sync the drawing area.
GPUBackendSetDrawingAreaCommand* cmd = sw_renderer->NewSetDrawingAreaCommand();
@ -1080,61 +1080,61 @@ void GPU_HW::FillDrawCommand(GPUBackendDrawCommand* cmd, GPURenderCommand rc) co
cmd->window = m_draw_mode.texture_window;
}
void GPU_HW::ReadSoftwareRendererVRAM(u32 x, u32 y, u32 width, u32 height)
void GPU_HW::ReadSoftwareRendererVRAM(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
{
m_sw_renderer->Sync(false);
}
void GPU_HW::UpdateSoftwareRendererVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, bool set_mask,
void GPU_HW::UpdateSoftwareRendererVRAM(uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data, bool set_mask,
bool check_mask)
{
const u32 num_words = width * height;
const uint32_t num_words = width * height;
GPUBackendUpdateVRAMCommand* cmd = m_sw_renderer->NewUpdateVRAMCommand(num_words);
FillBackendCommandParameters(cmd);
cmd->params.set_mask_while_drawing = set_mask;
cmd->params.check_mask_before_draw = check_mask;
cmd->x = static_cast<u16>(x);
cmd->y = static_cast<u16>(y);
cmd->width = static_cast<u16>(width);
cmd->height = static_cast<u16>(height);
std::memcpy(cmd->data, data, sizeof(u16) * num_words);
cmd->x = static_cast<uint16_t>(x);
cmd->y = static_cast<uint16_t>(y);
cmd->width = static_cast<uint16_t>(width);
cmd->height = static_cast<uint16_t>(height);
std::memcpy(cmd->data, data, sizeof(uint16_t) * num_words);
m_sw_renderer->PushCommand(cmd);
}
void GPU_HW::FillSoftwareRendererVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
void GPU_HW::FillSoftwareRendererVRAM(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color)
{
GPUBackendFillVRAMCommand* cmd = m_sw_renderer->NewFillVRAMCommand();
FillBackendCommandParameters(cmd);
cmd->x = static_cast<u16>(x);
cmd->y = static_cast<u16>(y);
cmd->width = static_cast<u16>(width);
cmd->height = static_cast<u16>(height);
cmd->x = static_cast<uint16_t>(x);
cmd->y = static_cast<uint16_t>(y);
cmd->width = static_cast<uint16_t>(width);
cmd->height = static_cast<uint16_t>(height);
cmd->color = color;
m_sw_renderer->PushCommand(cmd);
}
void GPU_HW::CopySoftwareRendererVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height)
void GPU_HW::CopySoftwareRendererVRAM(uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, uint32_t width, uint32_t height)
{
GPUBackendCopyVRAMCommand* cmd = m_sw_renderer->NewCopyVRAMCommand();
FillBackendCommandParameters(cmd);
cmd->src_x = static_cast<u16>(src_x);
cmd->src_y = static_cast<u16>(src_y);
cmd->dst_x = static_cast<u16>(dst_x);
cmd->dst_y = static_cast<u16>(dst_y);
cmd->width = static_cast<u16>(width);
cmd->height = static_cast<u16>(height);
cmd->src_x = static_cast<uint16_t>(src_x);
cmd->src_y = static_cast<uint16_t>(src_y);
cmd->dst_x = static_cast<uint16_t>(dst_x);
cmd->dst_y = static_cast<uint16_t>(dst_y);
cmd->width = static_cast<uint16_t>(width);
cmd->height = static_cast<uint16_t>(height);
m_sw_renderer->PushCommand(cmd);
}
void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
void GPU_HW::FillVRAM(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color)
{
IncludeVRAMDirtyRectangle(
Common::Rectangle<u32>::FromExtents(x, y, width, height).Clamped(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
Common::Rectangle<uint32_t>::FromExtents(x, y, width, height).Clamped(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
}
void GPU_HW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, bool set_mask, bool check_mask)
void GPU_HW::UpdateVRAM(uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data, bool set_mask, bool check_mask)
{
IncludeVRAMDirtyRectangle(Common::Rectangle<u32>::FromExtents(x, y, width, height));
IncludeVRAMDirtyRectangle(Common::Rectangle<uint32_t>::FromExtents(x, y, width, height));
if (check_mask)
{
@ -1143,10 +1143,10 @@ void GPU_HW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, b
}
}
void GPU_HW::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height)
void GPU_HW::CopyVRAM(uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, uint32_t width, uint32_t height)
{
IncludeVRAMDirtyRectangle(
Common::Rectangle<u32>::FromExtents(dst_x, dst_y, width, height).Clamped(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
Common::Rectangle<uint32_t>::FromExtents(dst_x, dst_y, width, height).Clamped(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
if (m_GPUSTAT.check_mask_before_draw)
{
@ -1181,7 +1181,7 @@ void GPU_HW::DispatchRenderCommand()
if (rc.raw_texture_enable)
{
texture_mode =
static_cast<GPUTextureMode>(static_cast<u8>(texture_mode) | static_cast<u8>(GPUTextureMode::RawTextureBit));
static_cast<GPUTextureMode>(static_cast<uint8_t>(texture_mode) | static_cast<uint8_t>(GPUTextureMode::RawTextureBit));
}
}
else
@ -1206,8 +1206,8 @@ void GPU_HW::DispatchRenderCommand()
{
static constexpr float transparent_alpha[4][2] = {{0.5f, 0.5f}, {1.0f, 1.0f}, {1.0f, 1.0f}, {0.25f, 1.0f}};
const float src_alpha_factor = transparent_alpha[static_cast<u32>(transparency_mode)][0];
const float dst_alpha_factor = transparent_alpha[static_cast<u32>(transparency_mode)][1];
const float src_alpha_factor = transparent_alpha[static_cast<uint32_t>(transparency_mode)][0];
const float dst_alpha_factor = transparent_alpha[static_cast<uint32_t>(transparency_mode)][1];
m_batch_ubo_dirty |= (m_batch_ubo_data.u_src_alpha_factor != src_alpha_factor ||
m_batch_ubo_data.u_dst_alpha_factor != dst_alpha_factor);
m_batch_ubo_data.u_src_alpha_factor = src_alpha_factor;
@ -1221,14 +1221,14 @@ void GPU_HW::DispatchRenderCommand()
{
m_batch.check_mask_before_draw = check_mask_before_draw;
m_batch.set_mask_while_drawing = set_mask_while_drawing;
m_batch_ubo_dirty |= (m_batch_ubo_data.u_set_mask_while_drawing != static_cast<u32>(set_mask_while_drawing));
m_batch_ubo_data.u_set_mask_while_drawing = static_cast<u32>(set_mask_while_drawing);
m_batch_ubo_dirty |= (m_batch_ubo_data.u_set_mask_while_drawing != static_cast<uint32_t>(set_mask_while_drawing));
m_batch_ubo_data.u_set_mask_while_drawing = static_cast<uint32_t>(set_mask_while_drawing);
}
m_batch.interlacing = IsInterlacedRenderingEnabled();
if (m_batch.interlacing)
{
const u32 displayed_field = GetActiveLineLSB();
const uint32_t displayed_field = GetActiveLineLSB();
m_batch_ubo_dirty |= (m_batch_ubo_data.u_interlaced_displayed_field != displayed_field);
m_batch_ubo_data.u_interlaced_displayed_field = displayed_field;
}
@ -1242,10 +1242,10 @@ void GPU_HW::DispatchRenderCommand()
{
m_draw_mode.ClearTextureWindowChangedFlag();
m_batch_ubo_data.u_texture_window_and[0] = static_cast<u32>(m_draw_mode.texture_window.and_x);
m_batch_ubo_data.u_texture_window_and[1] = static_cast<u32>(m_draw_mode.texture_window.and_y);
m_batch_ubo_data.u_texture_window_or[0] = static_cast<u32>(m_draw_mode.texture_window.or_x);
m_batch_ubo_data.u_texture_window_or[1] = static_cast<u32>(m_draw_mode.texture_window.or_y);
m_batch_ubo_data.u_texture_window_and[0] = static_cast<uint32_t>(m_draw_mode.texture_window.and_x);
m_batch_ubo_data.u_texture_window_and[1] = static_cast<uint32_t>(m_draw_mode.texture_window.and_y);
m_batch_ubo_data.u_texture_window_or[0] = static_cast<uint32_t>(m_draw_mode.texture_window.or_x);
m_batch_ubo_data.u_texture_window_or[1] = static_cast<uint32_t>(m_draw_mode.texture_window.or_y);
m_batch_ubo_dirty = true;
}
@ -1273,7 +1273,7 @@ void GPU_HW::FlushRender()
if (!m_batch_current_vertex_ptr)
return;
const u32 vertex_count = GetBatchVertexCount();
const uint32_t vertex_count = GetBatchVertexCount();
UnmapBatchVertexPointer(vertex_count);
if (vertex_count == 0)
@ -1294,7 +1294,7 @@ void GPU_HW::FlushRender()
DrawBatchVertices(m_batch.GetRenderMode(), m_batch_base_vertex, vertex_count);
}
GPU_HW::ShaderCompileProgressTracker::ShaderCompileProgressTracker(std::string title, u32 total)
GPU_HW::ShaderCompileProgressTracker::ShaderCompileProgressTracker(std::string title, uint32_t total)
: m_title(std::move(title)), m_min_time(Common::Timer::ConvertSecondsToValue(1.0)),
m_update_interval(Common::Timer::ConvertSecondsToValue(0.1)), m_start_time(Common::Timer::GetValue()),
m_last_update_time(0), m_progress(0), m_total(total)
@ -1305,7 +1305,7 @@ void GPU_HW::ShaderCompileProgressTracker::Increment()
{
m_progress++;
const u64 tv = Common::Timer::GetValue();
const uint64_t tv = Common::Timer::GetValue();
if ((tv - m_start_time) >= m_min_time && (tv - m_last_update_time) >= m_update_interval)
{
g_host_interface->DisplayLoadingScreen(m_title.c_str(), 0, static_cast<int>(m_total), static_cast<int>(m_progress));