Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-26 10:38:25 +0300
committerCampbell Barton <campbell@blender.org>2022-09-26 10:58:36 +0300
commit333e41eac6daf60c6aa9df0496a39c57d74b9c87 (patch)
tree5986e980fd64bc4ef1c3dda125a0f9dca4bab2c8 /source/blender/gpu/metal
parent0210c4df1793799a09a35e44be286dfca88769dc (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Use function style casts in C++ headers & source.
Diffstat (limited to 'source/blender/gpu/metal')
-rw-r--r--source/blender/gpu/metal/mtl_context.hh2
-rw-r--r--source/blender/gpu/metal/mtl_pso_descriptor_state.hh38
-rw-r--r--source/blender/gpu/metal/mtl_texture.hh16
3 files changed, 27 insertions, 29 deletions
diff --git a/source/blender/gpu/metal/mtl_context.hh b/source/blender/gpu/metal/mtl_context.hh
index 3ba33ebfa46..6229afcef79 100644
--- a/source/blender/gpu/metal/mtl_context.hh
+++ b/source/blender/gpu/metal/mtl_context.hh
@@ -352,7 +352,7 @@ struct MTLSamplerArray {
{
uint32_t hash = this->num_samplers;
for (int i = 0; i < this->num_samplers; i++) {
- hash ^= (uint32_t)this->mtl_sampler_flags[i] << (i % 3);
+ hash ^= uint32_t(this->mtl_sampler_flags[i]) << (i % 3);
}
return hash;
}
diff --git a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh
index 1906350679a..198d309874b 100644
--- a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh
+++ b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh
@@ -28,8 +28,8 @@ struct MTLVertexAttributeDescriptorPSO {
uint64_t hash() const
{
- return (uint64_t)((uint64_t)this->format ^ (this->offset << 4) ^ (this->buffer_index << 8) ^
- (this->format_conversion_mode << 12));
+ return uint64_t((uint64_t(this->format) ^ (this->offset << 4) ^ (this->buffer_index << 8) ^
+ (this->format_conversion_mode << 12)));
}
};
@@ -46,8 +46,7 @@ struct MTLVertexBufferLayoutDescriptorPSO {
uint64_t hash() const
{
- return (uint64_t)((uint64_t)this->step_function ^ (this->step_rate << 4) ^
- (this->stride << 8));
+ return uint64_t(uint64_t(this->step_function) ^ (this->step_rate << 4) ^ (this->stride << 8));
}
};
@@ -217,31 +216,30 @@ struct MTLRenderPipelineStateDescriptor {
* has collisions. */
uint64_t hash = this->vertex_descriptor.hash();
- hash ^= (uint64_t)this->num_color_attachments << 16; /* up to 6 (3 bits). */
- hash ^= (uint64_t)this->depth_attachment_format << 18; /* up to 555 (9 bits). */
- hash ^= (uint64_t)this->stencil_attachment_format << 20; /* up to 555 (9 bits). */
- hash ^= (uint64_t)(*(
- (uint64_t *)&this->vertex_descriptor.prim_topology_class)); /* Up to 3 (2 bits). */
+ hash ^= uint64_t(this->num_color_attachments) << 16; /* up to 6 (3 bits). */
+ hash ^= uint64_t(this->depth_attachment_format) << 18; /* up to 555 (9 bits). */
+ hash ^= uint64_t(this->stencil_attachment_format) << 20; /* up to 555 (9 bits). */
+ hash ^= uint64_t(
+ *((uint64_t *)&this->vertex_descriptor.prim_topology_class)); /* Up to 3 (2 bits). */
/* Only include elements in Hash if they are needed - avoids variable null assignments
* influencing hash. */
if (this->num_color_attachments > 0) {
- hash ^= (uint64_t)this->color_write_mask << 22; /* 4 bit bit-mask. */
- hash ^= (uint64_t)this->alpha_blend_op << 26; /* Up to 4 (3 bits). */
- hash ^= (uint64_t)this->rgb_blend_op << 29; /* Up to 4 (3 bits). */
- hash ^= (uint64_t)this->dest_alpha_blend_factor << 32; /* Up to 18 (5 bits). */
- hash ^= (uint64_t)this->dest_rgb_blend_factor << 37; /* Up to 18 (5 bits). */
- hash ^= (uint64_t)this->src_alpha_blend_factor << 42; /* Up to 18 (5 bits). */
- hash ^= (uint64_t)this->src_rgb_blend_factor << 47; /* Up to 18 (5 bits). */
+ hash ^= uint64_t(this->color_write_mask) << 22; /* 4 bit bit-mask. */
+ hash ^= uint64_t(this->alpha_blend_op) << 26; /* Up to 4 (3 bits). */
+ hash ^= uint64_t(this->rgb_blend_op) << 29; /* Up to 4 (3 bits). */
+ hash ^= uint64_t(this->dest_alpha_blend_factor) << 32; /* Up to 18 (5 bits). */
+ hash ^= uint64_t(this->dest_rgb_blend_factor) << 37; /* Up to 18 (5 bits). */
+ hash ^= uint64_t(this->src_alpha_blend_factor) << 42; /* Up to 18 (5 bits). */
+ hash ^= uint64_t(this->src_rgb_blend_factor) << 47; /* Up to 18 (5 bits). */
}
for (const uint c : IndexRange(GPU_FB_MAX_COLOR_ATTACHMENT)) {
- hash ^= (uint64_t)this->color_attachment_format[c] << (c + 52); // up to 555 (9 bits)
+ hash ^= uint64_t(this->color_attachment_format[c]) << (c + 52); /* Up to 555 (9 bits). */
}
- hash |= (uint64_t)((this->blending_enabled && (this->num_color_attachments > 0)) ? 1 : 0)
- << 62;
- hash ^= (uint64_t)this->point_size;
+ hash |= uint64_t((this->blending_enabled && (this->num_color_attachments > 0)) ? 1 : 0) << 62;
+ hash ^= uint64_t(this->point_size);
return hash;
}
diff --git a/source/blender/gpu/metal/mtl_texture.hh b/source/blender/gpu/metal/mtl_texture.hh
index 88d09e4e133..ebc9eb2e00e 100644
--- a/source/blender/gpu/metal/mtl_texture.hh
+++ b/source/blender/gpu/metal/mtl_texture.hh
@@ -51,9 +51,9 @@ struct TextureUpdateRoutineSpecialisation {
uint64_t hash() const
{
blender::DefaultHash<std::string> string_hasher;
- return (uint64_t)string_hasher(
+ return uint64_t(string_hasher(
this->input_data_type + this->output_data_type +
- std::to_string((this->component_count_input << 8) + this->component_count_output));
+ std::to_string((this->component_count_input << 8) + this->component_count_output)));
}
};
@@ -108,10 +108,10 @@ struct TextureReadRoutineSpecialisation {
uint64_t hash() const
{
blender::DefaultHash<std::string> string_hasher;
- return (uint64_t)string_hasher(this->input_data_type + this->output_data_type +
- std::to_string((this->component_count_input << 8) +
- this->component_count_output +
- (this->depth_format_mode << 28)));
+ return uint64_t(string_hasher(this->input_data_type + this->output_data_type +
+ std::to_string((this->component_count_input << 8) +
+ this->component_count_output +
+ (this->depth_format_mode << 28))));
}
};
@@ -138,12 +138,12 @@ struct MTLSamplerState {
operator uint() const
{
- return (uint)state;
+ return uint(state);
}
operator uint64_t() const
{
- return (uint64_t)state;
+ return uint64_t(state);
}
};