Cleanup: Various clang-tidy warnings in gpu

Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
Brecht Van Lommel
2025-01-26 20:08:03 +01:00
parent 61eedabae9
commit c7502b092d
73 changed files with 132 additions and 171 deletions

View File

@@ -24,7 +24,6 @@
#include "GPU_index_buffer.hh"
#include "GPU_shader.hh"
#include "GPU_storage_buffer.hh"
#include "GPU_uniform_buffer.hh"
#include "GPU_vertex_buffer.hh"
struct GPUShader;

View File

@@ -12,7 +12,6 @@
#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
namespace blender::gpu {
class Batch;

View File

@@ -11,8 +11,6 @@
#define PROGRAM_NO_OPTI 0
// #define GPU_NO_USE_PY_REFERENCES
#include "BLI_sys_types.h"
/* GPU_INLINE */
#if defined(_MSC_VER)
# define GPU_INLINE static __forceinline

View File

@@ -181,7 +181,7 @@ struct SpecializationConstant {
float f;
};
inline bool operator==(const Value &other) const
bool operator==(const Value &other) const
{
return u == other.u;
}
@@ -213,7 +213,7 @@ struct SpecializationConstant {
this->value.u = value ? 1 : 0;
}
inline bool operator==(const SpecializationConstant &b) const
bool operator==(const SpecializationConstant &b) const
{
return this->type == b.type && this->name == b.name && this->value == b.value;
}

View File

@@ -10,8 +10,6 @@
#pragma once
#include "GPU_batch.hh"
#include "GPU_common.hh"
#include "GPU_platform.hh"
/* GPU back-ends abstract the differences between different APIs. #GPU_context_create

View File

@@ -61,8 +61,6 @@
#pragma once
#include "BLI_sys_types.h"
#define GPU_DEBUG_SHADER_COMPILATION_GROUP "Shader Compilation"
void GPU_debug_group_begin(const char *name);

View File

@@ -11,12 +11,14 @@
#pragma once
#include "GPU_batch.hh"
#include "GPU_immediate_util.hh"
#include "GPU_immediate_util.hh" /* IWYU pragma: export */
#include "GPU_primitive.hh"
#include "GPU_shader.hh"
#include "GPU_texture.hh"
#include "GPU_vertex_format.hh"
struct GPUUniformBuf;
/** Returns a cleared vertex format, ready for #add_attr. */
GPUVertFormat *immVertexFormat();

View File

@@ -8,8 +8,6 @@
#pragma once
#include "BLI_utildefines.h"
void GPU_init();
void GPU_exit();
bool GPU_is_init();

View File

@@ -14,8 +14,6 @@
#include "DNA_image_types.h"
#include "DNA_listBase.h"
#include "BLI_sys_types.h" /* for bool */
#include "GPU_shader.hh" /* for GPUShaderCreateInfo */
#include "GPU_texture.hh" /* for GPUSamplerState */

View File

@@ -8,8 +8,6 @@
#pragma once
#include "BLI_sys_types.h"
struct GPUShader;
/**

View File

@@ -11,10 +11,9 @@
#include <string>
#include "BLI_span.hh"
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "GPU_platform_backend_enum.h"
#include "GPU_platform_backend_enum.h" // IWYU pragma: export
/* GPU platform support */

View File

@@ -11,7 +11,7 @@
#pragma once
#include "BLI_assert.h"
#include "GPU_common.hh"
#include "BLI_sys_types.h"
enum GPUPrimType {
GPU_PRIM_POINTS,

View File

@@ -75,6 +75,7 @@
# pragma once
# include "BLI_assert.h"
# include "BLI_sys_types.h"
# include "BLI_math_matrix_types.hh"
# include "BLI_math_vector_types.hh"

View File

@@ -17,8 +17,6 @@
#include "BLI_assert.h"
#include "BLI_utildefines.h"
#include "GPU_state.hh"
namespace blender::gpu {
class VertBuf;
}

View File

@@ -13,6 +13,7 @@
#include "BLI_span.hh"
#include "BLI_utildefines.h"
#include "GPU_common.hh"
#include "GPU_vertex_format.hh"
enum GPUVertBufStatus {

View File

@@ -12,9 +12,8 @@
#include "BLI_assert.h"
#include "BLI_compiler_compat.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "GPU_common.hh"
struct GPUShader;

View File

@@ -9,7 +9,6 @@
#pragma once
#include "gpu_backend.hh"
#include "gpu_capabilities_private.hh"
#include "gpu_platform_private.hh"
#include "dummy_batch.hh"

View File

@@ -20,7 +20,7 @@ class DummyContext : public Context {
{
back_left = active_fb = new DummyFrameBuffer("DummyFramebuffer");
}
~DummyContext()
~DummyContext() override
{
free_framebuffers();
}
@@ -34,7 +34,7 @@ class DummyContext : public Context {
void memory_statistics_get(int * /*r_total_mem*/, int * /*r_free_mem*/) override {}
void debug_group_begin(const char *, int) override {}
void debug_group_begin(const char * /*unused*/, int /*unused*/) override {}
void debug_group_end() override {}
bool debug_capture_begin(const char * /*title*/) override
{

View File

@@ -8,6 +8,10 @@
#pragma once
#include "BLI_sys_types.h"
#include "GPU_vertex_buffer.hh"
namespace blender::gpu {
class DummyVertexBuffer : public VertBuf {

View File

@@ -71,33 +71,31 @@ static inline ColorTheme4f get_debug_group_color(StringRefNull name)
if (name == "EEVEE") {
return ColorTheme4f(1.0, 0.5, 0.0, 1.0);
}
else if (name == "External") {
if (name == "External") {
return ColorTheme4f(0.0, 0.0, 1.0, 1.0);
}
else if (name == "GpencilMode") {
if (name == "GpencilMode") {
return ColorTheme4f(1.0, 1.0, 0.0, 1.0);
}
else if (name == "UV/Image") {
if (name == "UV/Image") {
return ColorTheme4f(0.0, 1.0, 1.0, 1.0);
}
else if (name == "Overlay") {
if (name == "Overlay") {
return ColorTheme4f(0.0, 1.0, 0.5, 1.0);
}
else if (name == "Workbench") {
if (name == "Workbench") {
return ColorTheme4f(0.0, 0.7, 1.0, 1.0);
}
else if (name == "Cycles") {
if (name == "Cycles") {
return ColorTheme4f(0.0, 0.5, 1.0, 1.0);
}
else if (name == "BackBuffer.Blit") {
if (name == "BackBuffer.Blit") {
return ColorTheme4f(0.5, 0.7, 1.0, 1.0);
}
else if (name == "Compositor") {
if (name == "Compositor") {
return ColorTheme4f(1.0, 0.5, 0.7, 1.0);
}
else {
return GPU_DEBUG_GROUP_COLOR_DEFAULT;
}
return GPU_DEBUG_GROUP_COLOR_DEFAULT;
}
} // namespace debug

View File

@@ -9,14 +9,11 @@
* Contains VAOs + VBOs + Shader representing a drawable entity.
*/
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "BLI_utildefines.h"
#include "GPU_batch.hh"
#include "GPU_batch_presets.hh"
#include "GPU_platform.hh"
#include "GPU_shader.hh"
#include "GPU_index_buffer.hh"
@@ -328,14 +325,12 @@ void GPU_batch_bind_as_resources(Batch *batch, GPUShader *shader)
/** \name Drawing / Drawcall functions
* \{ */
void GPU_batch_draw_parameter_get(Batch *gpu_batch,
void GPU_batch_draw_parameter_get(Batch *batch,
int *r_vertex_count,
int *r_vertex_first,
int *r_base_index,
int *r_instance_count)
{
Batch *batch = static_cast<Batch *>(gpu_batch);
if (batch->elem) {
*r_vertex_count = batch->elem_()->index_len_get();
*r_vertex_first = batch->elem_()->index_start_get();
@@ -393,7 +388,7 @@ static void polyline_draw_workaround(
Batch *tri_batch = Context::get()->polyline_batch_get();
GPU_batch_set_shader(tri_batch, batch->shader);
int vert_stride_count[3] = {(batch->prim_type == GPU_PRIM_LINES) ? 2 : 1, int(vertex_count), 0};
int vert_stride_count[3] = {(batch->prim_type == GPU_PRIM_LINES) ? 2 : 1, vertex_count, 0};
GPU_shader_uniform_3iv(batch->shader, "gpu_vert_stride_count_offset", vert_stride_count);
/* Assume GPU_FETCH_FLOAT for now. A bit cumbersome to assert for this or to find the correct
* attribute. */
@@ -451,12 +446,11 @@ void GPU_batch_draw_instance_range(Batch *batch, int instance_first, int instanc
}
void GPU_batch_draw_advanced(
Batch *gpu_batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
{
BLI_assert(gpu_batch != nullptr);
BLI_assert(batch != nullptr);
BLI_assert(Context::get()->shader != nullptr);
Context::get()->assert_framebuffer_shader_compatibility(Context::get()->shader);
Batch *batch = static_cast<Batch *>(gpu_batch);
if (vertex_count == 0) {
if (batch->elem) {
@@ -482,25 +476,23 @@ void GPU_batch_draw_advanced(
batch->draw(vertex_first, vertex_count, instance_first, instance_count);
}
void GPU_batch_draw_indirect(Batch *gpu_batch, GPUStorageBuf *indirect_buf, intptr_t offset)
void GPU_batch_draw_indirect(Batch *batch, GPUStorageBuf *indirect_buf, intptr_t offset)
{
BLI_assert(gpu_batch != nullptr);
BLI_assert(batch != nullptr);
BLI_assert(indirect_buf != nullptr);
BLI_assert(Context::get()->shader != nullptr);
Context::get()->assert_framebuffer_shader_compatibility(Context::get()->shader);
Batch *batch = static_cast<Batch *>(gpu_batch);
batch->draw_indirect(indirect_buf, offset);
}
void GPU_batch_multi_draw_indirect(
Batch *gpu_batch, GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
Batch *batch, GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
{
BLI_assert(gpu_batch != nullptr);
BLI_assert(batch != nullptr);
BLI_assert(indirect_buf != nullptr);
BLI_assert(Context::get()->shader != nullptr);
Context::get()->assert_framebuffer_shader_compatibility(Context::get()->shader);
Batch *batch = static_cast<Batch *>(gpu_batch);
batch->multi_draw_indirect(indirect_buf, count, offset, stride);
}

View File

@@ -9,7 +9,6 @@
#include "BLI_listbase.h"
#include "BLI_math_vector_types.hh"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"

View File

@@ -8,9 +8,9 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "DNA_vec_types.h"
#include "BLI_polyfill_2d.h"
#include "BLI_rect.h"
#include "BLI_sort_utils.h"
#include "BLI_utildefines.h"
@@ -25,7 +25,7 @@ blender::gpu::Batch *GPU_batch_tris_from_poly_2d_encoded(const uchar *polys_flat
uint polys_flat_len,
const rctf *rect)
{
const uchar(*polys)[2] = static_cast<const uchar(*)[2]>((const void *)polys_flat);
const uchar(*polys)[2] = reinterpret_cast<const uchar(*)[2]>(polys_flat);
const uint polys_len = polys_flat_len / 2;
BLI_assert(polys_flat_len == polys_len * 2);
@@ -114,7 +114,7 @@ blender::gpu::Batch *GPU_batch_wire_from_poly_2d_encoded(const uchar *polys_flat
uint polys_flat_len,
const rctf *rect)
{
const uchar(*polys)[2] = static_cast<const uchar(*)[2]>((const void *)polys_flat);
const uchar(*polys)[2] = reinterpret_cast<const uchar(*)[2]>(polys_flat);
const uint polys_len = polys_flat_len / 2;
BLI_assert(polys_flat_len == polys_len * 2);

View File

@@ -8,7 +8,7 @@
#pragma once
#include "GPU_platform.hh"
#include "BLI_sys_types.h"
namespace blender::gpu {

View File

@@ -11,7 +11,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_customdata_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
#include "BLI_ghash.h"
@@ -22,7 +21,6 @@
#include "BLI_string.h"
#include "BLI_threads.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
#include "BKE_cryptomatte.hh"
#include "BKE_material.hh"

View File

@@ -13,16 +13,14 @@
* - free can be called from any thread
*/
#include "GHOST_C-api.h"
#include "BKE_global.hh"
#include "BLI_assert.h"
#include "BLI_utildefines.h"
#include "BLI_vector_set.hh"
#include "GHOST_Types.h"
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"
#include "GPU_batch.hh"
#include "gpu_backend.hh"
@@ -44,7 +42,6 @@
#include "dummy_backend.hh"
#include <mutex>
#include <vector>
using namespace blender::gpu;

View File

@@ -10,8 +10,6 @@
#pragma once
#include "MEM_guardedalloc.h"
#include "BKE_global.hh"
#include "GPU_batch.hh"

View File

@@ -12,9 +12,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "GPU_batch.hh"
#include "GPU_capabilities.hh"
#include "GPU_shader.hh"
#include "GPU_texture.hh"
#include "gpu_backend.hh"

View File

@@ -13,8 +13,6 @@
#include "BLI_math_vector.h"
#include "BLI_span.hh"
#include "MEM_guardedalloc.h"
#include "GPU_framebuffer.hh"
struct GPUTexture;
@@ -39,12 +37,12 @@ enum GPUAttachmentType : int {
#define GPU_FB_MAX_COLOR_ATTACHMENT (GPU_FB_MAX_ATTACHMENT - GPU_FB_COLOR_ATTACHMENT0)
inline constexpr GPUAttachmentType operator-(GPUAttachmentType a, int b)
constexpr GPUAttachmentType operator-(GPUAttachmentType a, int b)
{
return static_cast<GPUAttachmentType>(int(a) - b);
}
inline constexpr GPUAttachmentType operator+(GPUAttachmentType a, int b)
constexpr GPUAttachmentType operator+(GPUAttachmentType a, int b)
{
return static_cast<GPUAttachmentType>(int(a) + b);
}
@@ -133,7 +131,7 @@ class FrameBuffer {
virtual void subpass_transition_impl(const GPUAttachmentState depth_attachment_state,
Span<GPUAttachmentState> color_attachment_states) = 0;
inline void set_color_attachment_bit(GPUAttachmentType type, bool value)
void set_color_attachment_bit(GPUAttachmentType type, bool value)
{
if (type >= GPU_FB_COLOR_ATTACHMENT0) {
int color_index = type - GPU_FB_COLOR_ATTACHMENT0;
@@ -156,7 +154,7 @@ class FrameBuffer {
uint get_bits_per_pixel();
/* Sets the size after creation. */
inline void size_set(int width, int height)
void size_set(int width, int height)
{
width_ = width;
height_ = height;
@@ -164,7 +162,7 @@ class FrameBuffer {
}
/* Sets the size for frame-buffer with no attachments. */
inline void default_size_set(int width, int height)
void default_size_set(int width, int height)
{
width_ = width;
height_ = height;
@@ -172,7 +170,7 @@ class FrameBuffer {
dirty_state_ = true;
}
inline void viewport_set(const int viewport[4])
void viewport_set(const int viewport[4])
{
if (!equals_v4v4_int(viewport_[0], viewport)) {
copy_v4_v4_int(viewport_[0], viewport);
@@ -181,7 +179,7 @@ class FrameBuffer {
multi_viewport_ = false;
}
inline void viewport_multi_set(const int viewports[GPU_MAX_VIEWPORTS][4])
void viewport_multi_set(const int viewports[GPU_MAX_VIEWPORTS][4])
{
for (size_t i = 0; i < GPU_MAX_VIEWPORTS; i++) {
if (!equals_v4v4_int(viewport_[i], viewports[i])) {
@@ -192,7 +190,7 @@ class FrameBuffer {
multi_viewport_ = true;
}
inline void scissor_set(const int scissor[4])
void scissor_set(const int scissor[4])
{
if (!equals_v4v4_int(scissor_, scissor)) {
copy_v4_v4_int(scissor_, scissor);
@@ -200,40 +198,40 @@ class FrameBuffer {
}
}
inline void scissor_test_set(bool test)
void scissor_test_set(bool test)
{
scissor_test_ = test;
dirty_state_ = true;
}
inline void viewport_get(int r_viewport[4]) const
void viewport_get(int r_viewport[4]) const
{
copy_v4_v4_int(r_viewport, viewport_[0]);
}
inline void scissor_get(int r_scissor[4]) const
void scissor_get(int r_scissor[4]) const
{
copy_v4_v4_int(r_scissor, scissor_);
}
inline bool scissor_test_get() const
bool scissor_test_get() const
{
return scissor_test_;
}
inline void viewport_reset()
void viewport_reset()
{
int viewport_rect[4] = {0, 0, width_, height_};
viewport_set(viewport_rect);
}
inline void scissor_reset()
void scissor_reset()
{
int scissor_rect[4] = {0, 0, width_, height_};
scissor_set(scissor_rect);
}
inline GPUTexture *depth_tex() const
GPUTexture *depth_tex() const
{
if (attachments_[GPU_FB_DEPTH_ATTACHMENT].tex) {
return attachments_[GPU_FB_DEPTH_ATTACHMENT].tex;
@@ -241,27 +239,27 @@ class FrameBuffer {
return attachments_[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;
};
inline GPUTexture *color_tex(int slot) const
GPUTexture *color_tex(int slot) const
{
return attachments_[GPU_FB_COLOR_ATTACHMENT0 + slot].tex;
};
inline const char *name_get() const
const char *name_get() const
{
return name_;
};
inline void set_use_explicit_loadstore(bool use_explicit_loadstore)
void set_use_explicit_loadstore(bool use_explicit_loadstore)
{
use_explicit_load_store_ = use_explicit_loadstore;
}
inline bool get_use_explicit_loadstore() const
bool get_use_explicit_loadstore() const
{
return use_explicit_load_store_;
}
inline uint16_t get_color_attachments_bitset()
uint16_t get_color_attachments_bitset()
{
return color_attachments_bits_;
}

View File

@@ -15,6 +15,7 @@
#include "GPU_immediate.hh"
#include "GPU_matrix.hh"
#include "GPU_texture.hh"
#include "GPU_uniform_buffer.hh"
#include "gpu_context_private.hh"
#include "gpu_immediate_private.hh"

View File

@@ -8,7 +8,6 @@
* GPU immediate mode drawing utilities
*/
#include <cstdio>
#include <cstring>
#include "BLI_math_rotation.h"

View File

@@ -21,6 +21,7 @@
#include "GPU_capabilities.hh"
#include "GPU_compute.hh"
#include "GPU_platform.hh"
#include "GPU_state.hh"
#include <algorithm> /* For `min/max`. */
#include <cstring>
@@ -529,7 +530,7 @@ void GPU_indexbuf_create_subrange_in_place(IndexBuf *elem,
void GPU_indexbuf_read(IndexBuf *elem, uint32_t *data)
{
return elem->read(data);
elem->read(data);
}
void GPU_indexbuf_discard(IndexBuf *elem)

View File

@@ -7,7 +7,6 @@
*/
#include "GPU_init_exit.hh" /* interface */
#include "BLI_sys_types.h"
#include "GPU_batch.hh"
#include "intern/gpu_codegen.hh"

View File

@@ -8,8 +8,6 @@
* Manages materials, lights and textures.
*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include "MEM_guardedalloc.h"

View File

@@ -588,7 +588,7 @@ const float (*GPU_matrix_normal_get(float m[3][3]))[3]
m = temp3;
}
copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(nullptr));
copy_m3_m4(m, GPU_matrix_model_view_get(nullptr));
invert_m3(m);
transpose_m3(m);

View File

@@ -10,13 +10,11 @@
#pragma once
#include "DNA_customdata_types.h"
#include "DNA_listBase.h"
#include "BLI_ghash.h"
#include "GPU_material.hh"
#include "GPU_shader.hh"
struct GPUNode;
struct GPUOutput;

View File

@@ -11,8 +11,6 @@
#include <cstdlib>
#include <cstring>
#include "DNA_userdef_types.h"
#include "GPU_select.hh"
#include "BLI_rect.h"

View File

@@ -25,7 +25,7 @@
#include "gpu_select_private.hh"
#include "BLI_strict_flags.h" /* Keep last. */
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
// #define DEBUG_PRINT

View File

@@ -16,8 +16,6 @@
#include "GPU_select.hh"
#include "GPU_state.hh"
#include "MEM_guardedalloc.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"

View File

@@ -6,11 +6,8 @@
* \ingroup gpu
*/
#include "MEM_guardedalloc.h"
#include "BLI_math_matrix.h"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "GPU_capabilities.hh"
#include "GPU_debug.hh"

View File

@@ -8,7 +8,6 @@
#include "BLI_utildefines.h"
#include "GPU_capabilities.hh"
#include "GPU_shader.hh"
#include "gpu_shader_private.hh"

View File

@@ -11,7 +11,6 @@
#include "BLI_map.hh"
#include "BLI_set.hh"
#include "BLI_string_ref.hh"
#include "BLI_threads.h"
#include "BKE_global.hh"
@@ -19,7 +18,6 @@
#include "GPU_context.hh"
#include "GPU_platform.hh"
#include "GPU_shader.hh"
#include "GPU_texture.hh"
#include "gpu_shader_create_info.hh"
#include "gpu_shader_create_info_private.hh"

View File

@@ -600,7 +600,7 @@ struct StageInterfaceInfo {
StageInterfaceInfo(const char *name_, const char *instance_name_ = "")
: name(name_), instance_name(instance_name_){};
~StageInterfaceInfo(){};
~StageInterfaceInfo() = default;
using Self = StageInterfaceInfo;
@@ -657,11 +657,11 @@ struct ShaderCreateInfo {
/** Manually set builtins. */
BuiltinBits builtins_ = BuiltinBits::NONE;
/** Manually set generated code. */
std::string vertex_source_generated = "";
std::string fragment_source_generated = "";
std::string compute_source_generated = "";
std::string geometry_source_generated = "";
std::string typedef_source_generated = "";
std::string vertex_source_generated;
std::string fragment_source_generated;
std::string compute_source_generated;
std::string geometry_source_generated;
std::string typedef_source_generated;
/** Manually set generated dependencies. */
Vector<StringRefNull, 0> dependencies_generated;
@@ -896,7 +896,7 @@ struct ShaderCreateInfo {
public:
ShaderCreateInfo(const char *name) : name_(name){};
~ShaderCreateInfo(){};
~ShaderCreateInfo() = default;
using Self = ShaderCreateInfo;
@@ -1383,13 +1383,13 @@ struct ShaderCreateInfo {
};
/* TODO(@fclem): Order the resources. */
for (auto &res : info.batch_resources_) {
for (const auto &res : info.batch_resources_) {
print_resource(res);
}
for (auto &res : info.pass_resources_) {
for (const auto &res : info.pass_resources_) {
print_resource(res);
}
for (auto &res : info.geometry_resources_) {
for (const auto &res : info.geometry_resources_) {
print_resource(res);
}
return stream;
@@ -1397,17 +1397,17 @@ struct ShaderCreateInfo {
bool has_resource_type(Resource::BindType bind_type) const
{
for (auto &res : batch_resources_) {
for (const auto &res : batch_resources_) {
if (res.bind_type == bind_type) {
return true;
}
}
for (auto &res : pass_resources_) {
for (const auto &res : pass_resources_) {
if (res.bind_type == bind_type) {
return true;
}
}
for (auto &res : geometry_resources_) {
for (const auto &res : geometry_resources_) {
if (res.bind_type == bind_type) {
return true;
}

View File

@@ -13,12 +13,10 @@
#include <iomanip>
#include <iostream>
#include <regex>
#include <sstream>
#include <string>
#include "BLI_ghash.h"
#include "BLI_map.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "gpu_material_library.hh"
@@ -27,8 +25,6 @@
#include "../glsl_preprocess/glsl_preprocess.hh"
#include "GPU_context.hh"
extern "C" {
#define SHADER_SOURCE(datatoc, filename, filepath) extern char datatoc[];
#include "glsl_compositor_source_list.h"
@@ -302,7 +298,7 @@ struct GPUSource {
name.copy_utf8_truncated(func->name, sizeof(func->name));
func->source = reinterpret_cast<void *>(this);
func->totparam = 0;
while (1) {
while (true) {
StringRef arg_qual = pop_token(line);
StringRef arg_type = pop_token(line);
if (arg_qual.is_empty()) {

View File

@@ -16,7 +16,7 @@
#include <cstring> /* required for STREQ later on. */
#include "BLI_hash.h"
#include "BLI_utildefines.h"
#include "BLI_sys_types.h"
#include "GPU_shader.hh"
#include "GPU_vertex_format.hh" /* GPU_VERT_ATTR_MAX_LEN */
@@ -82,63 +82,63 @@ class ShaderInterface {
void debug_print() const;
inline const ShaderInput *attr_get(const StringRefNull name) const
const ShaderInput *attr_get(const StringRefNull name) const
{
return input_lookup(inputs_, attr_len_, name);
}
inline const ShaderInput *attr_get(const int binding) const
const ShaderInput *attr_get(const int binding) const
{
return input_lookup(inputs_, attr_len_, binding);
}
inline const ShaderInput *ubo_get(const StringRefNull name) const
const ShaderInput *ubo_get(const StringRefNull name) const
{
return input_lookup(inputs_ + attr_len_, ubo_len_, name);
}
inline const ShaderInput *ubo_get(const int binding) const
const ShaderInput *ubo_get(const int binding) const
{
return input_lookup(inputs_ + attr_len_, ubo_len_, binding);
}
inline const ShaderInput *uniform_get(const StringRefNull name) const
const ShaderInput *uniform_get(const StringRefNull name) const
{
return input_lookup(inputs_ + attr_len_ + ubo_len_, uniform_len_, name);
}
inline const ShaderInput *texture_get(const int binding) const
const ShaderInput *texture_get(const int binding) const
{
return input_lookup(inputs_ + attr_len_ + ubo_len_, uniform_len_, binding);
}
inline const ShaderInput *ssbo_get(const StringRefNull name) const
const ShaderInput *ssbo_get(const StringRefNull name) const
{
return input_lookup(inputs_ + attr_len_ + ubo_len_ + uniform_len_, ssbo_len_, name);
}
inline const ShaderInput *ssbo_get(const int binding) const
const ShaderInput *ssbo_get(const int binding) const
{
return input_lookup(inputs_ + attr_len_ + ubo_len_ + uniform_len_, ssbo_len_, binding);
}
inline const ShaderInput *constant_get(const StringRefNull name) const
const ShaderInput *constant_get(const StringRefNull name) const
{
return input_lookup(
inputs_ + attr_len_ + ubo_len_ + uniform_len_ + ssbo_len_, constant_len_, name);
}
inline const char *input_name_get(const ShaderInput *input) const
const char *input_name_get(const ShaderInput *input) const
{
return name_buffer_ + input->name_offset;
}
/* Returns uniform location. */
inline int32_t uniform_builtin(const GPUUniformBuiltin builtin) const
int32_t uniform_builtin(const GPUUniformBuiltin builtin) const
{
BLI_assert(builtin >= 0 && builtin < GPU_NUM_UNIFORMS);
return builtins_[builtin];
}
/* Returns binding position. */
inline int32_t ubo_builtin(const GPUUniformBlockBuiltin builtin) const
int32_t ubo_builtin(const GPUUniformBlockBuiltin builtin) const
{
BLI_assert(builtin >= 0 && builtin < GPU_NUM_UNIFORM_BLOCKS);
return builtin_blocks_[builtin];

View File

@@ -9,8 +9,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_dynstr.h"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLI_vector.hh"
#include "GPU_storage_buffer.hh"

View File

@@ -17,7 +17,6 @@
#include "BLI_map.hh"
#include <mutex>
#include <string>
namespace blender::gpu {
@@ -124,17 +123,17 @@ class Shader {
/* DEPRECATED: Kept only because of BGL API. */
virtual int program_handle_get() const = 0;
inline StringRefNull name_get() const
StringRefNull name_get() const
{
return name;
}
inline void parent_set(Shader *parent)
void parent_set(Shader *parent)
{
parent_shader_ = parent;
}
inline Shader *parent_get() const
Shader *parent_get() const
{
return parent_shader_;
}

View File

@@ -9,14 +9,12 @@
#include "MEM_guardedalloc.h"
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BKE_global.hh"
#include "gpu_backend.hh"
#include "GPU_material.hh"
#include "GPU_storage_buffer.hh"
#include "GPU_vertex_buffer.hh" /* For GPUUsageType. */

View File

@@ -8,7 +8,6 @@
#pragma once
#include "BLI_span.hh"
#include "BLI_sys_types.h"
struct GPUStorageBuf;

View File

@@ -954,7 +954,7 @@ int GPU_texture_opengl_bindcode(const GPUTexture *texture)
void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *r_size)
{
return unwrap(texture)->mip_size_get(mip_level, r_size);
unwrap(texture)->mip_size_get(mip_level, r_size);
}
/** \} */

View File

@@ -766,8 +766,7 @@ inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_form
}
/* Definitely not complete, edit according to the gl specification. */
constexpr inline bool validate_data_format(eGPUTextureFormat tex_format,
eGPUDataFormat data_format)
constexpr bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
{
switch (tex_format) {
/* Formats texture & render-buffer */

View File

@@ -9,8 +9,9 @@
#include "MEM_guardedalloc.h"
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_listbase.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BKE_global.hh"

View File

@@ -24,8 +24,8 @@
#include "GPU_framebuffer.hh"
#include "GPU_immediate.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "GPU_texture.hh"
#include "GPU_uniform_buffer.hh"
#include "GPU_viewport.hh"
#include "DRW_engine.hh"

View File

@@ -7,12 +7,9 @@
*/
#pragma once
#include "MEM_guardedalloc.h"
#include "gpu_context_private.hh"
#include "GPU_common_types.hh"
#include "GPU_context.hh"
/* Don't generate OpenGL deprecation warning. This is a known thing, and is not something easily
* solvable in a short term. */

View File

@@ -17,8 +17,8 @@
#include "mtl_shader_interface.hh"
#include "mtl_shader_interface_type.hh"
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"

View File

@@ -6,12 +6,17 @@
* \ingroup gpu
*/
#include <string>
#include "BKE_global.hh"
#if defined(WIN32)
# include "BLI_winstuff.h"
#endif
#include "BLI_string_ref.hh"
#include "BLI_subprocess.hh"
#include "BLI_threads.h"
#include "BLI_vector.hh"
#include "DNA_userdef_types.h"
#include "gpu_capabilities_private.hh"

View File

@@ -20,6 +20,7 @@
#include "gpu_shader_private.hh"
#include <functional>
#include <mutex>
namespace blender::gpu {

View File

@@ -6,10 +6,10 @@
#include "GPU_capabilities.hh"
#include "GPU_compute.hh"
#include "GPU_state.hh"
#include "GPU_vertex_buffer.hh"
#include "GPU_vertex_format.hh"
#include "BLI_index_range.hh"
#include "BLI_math_vector_types.hh"
#include "gpu_testing.hh"

View File

@@ -10,6 +10,7 @@
#include "GPU_capabilities.hh"
#include "GPU_compute.hh"
#include "GPU_state.hh"
#include "GPU_storage_buffer.hh"
#include "GPU_texture.hh"

View File

@@ -4,9 +4,14 @@
#include "testing/testing.h"
#include "GPU_batch.hh"
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"
#include "GPU_shader.hh"
#include "GPU_state.hh"
#include "GPU_vertex_buffer.hh"
#include "GPU_vertex_format.hh"
#include "gpu_testing.hh"
#include "BLI_math_vector.hh"

View File

@@ -11,6 +11,7 @@
#include "GPU_context.hh"
#include "GPU_debug.hh"
#include "GPU_init_exit.hh"
#include "gpu_testing.hh"
#include "GHOST_C-api.h"

View File

@@ -7,6 +7,7 @@
#include "GPU_framebuffer.hh"
#include "GPU_immediate.hh"
#include "GPU_shader_builtin.hh"
#include "GPU_state.hh"
#include "gpu_testing.hh"
#include "BLI_math_vector.hh"

View File

@@ -4,8 +4,6 @@
#include "testing/testing.h"
#include "MEM_guardedalloc.h"
#include "GPU_index_buffer.hh"
#include "gpu_testing.hh"

View File

@@ -7,6 +7,7 @@
#include "GPU_capabilities.hh"
#include "GPU_compute.hh"
#include "GPU_shader.hh"
#include "GPU_state.hh"
#include "GPU_storage_buffer.hh"
#include "BLI_math_vector.hh"

View File

@@ -14,6 +14,7 @@
#include "GPU_index_buffer.hh"
#include "GPU_shader.hh"
#include "GPU_shader_shared.hh"
#include "GPU_state.hh"
#include "GPU_texture.hh"
#include "GPU_vertex_buffer.hh"
#include "GPU_vertex_format.hh"
@@ -384,7 +385,7 @@ static void gpu_shader_lib_test(const char *test_src_name, const char *additiona
if (ELEM(test.status, TEST_STATUS_NONE, TEST_STATUS_PASSED)) {
continue;
}
else if (test.status == TEST_STATUS_FAILED) {
if (test.status == TEST_STATUS_FAILED) {
ADD_FAILURE_AT(test_src_name, test.line)
<< "Value of: " << print_test_line(test_src, test.line) << "\n"
<< " Actual: " << print_test_data(test.expect, TestType(test.type)) << "\n"

View File

@@ -10,7 +10,9 @@
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"
#include "GPU_shader.hh"
#include "GPU_state.hh"
#include "GPU_storage_buffer.hh"
#include "GPU_vertex_format.hh"
#include "BLI_math_vector.hh"
#include "BLI_utility_mixins.hh"

View File

@@ -9,7 +9,7 @@
#include "GPU_batch.hh"
#include "GPU_batch_presets.hh"
#include "GPU_framebuffer.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "BLI_math_vector.hh"

View File

@@ -6,10 +6,10 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_vector.hh"
#include "BLI_vector.hh"
#include "BLI_math_vector_types.hh"
#include "GPU_context.hh"
#include "GPU_state.hh"
#include "GPU_texture.hh"
#include "gpu_texture_private.hh"

View File

@@ -4,10 +4,10 @@
#include "testing/testing.h"
#include "GPU_context.hh"
#include "GPU_batch.hh"
#include "GPU_framebuffer.hh"
#include "GPU_immediate.hh"
#include "GPU_shader.hh"
#include "GPU_state.hh"
#include "GPU_vertex_buffer.hh"
#include "GPU_vertex_format.hh"

View File

@@ -19,6 +19,7 @@
#include "vk_mem_alloc.h"
#include "GPU_index_buffer.hh"
#include "GPU_state.hh"
#include "gpu_query.hh"
#include "gpu_shader_create_info.hh"
#include "gpu_texture_private.hh"

View File

@@ -16,6 +16,8 @@
#include "shaderc/shaderc.hpp"
#include <mutex>
namespace blender::gpu {
class VKShader;
class VKShaderModule;

View File

@@ -24,6 +24,7 @@
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"
#include "GPU_state.hh"
#include "GPU_texture.hh"
#include "GPU_viewport.hh"

View File

@@ -13,6 +13,7 @@
#include <Python.h>
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "DNA_image_types.h"