mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
Cleanup: use const arguments
This commit is contained in:
parent
4dfd8e33e0
commit
d8c2301ee8
6 changed files with 65 additions and 57 deletions
|
@ -31,7 +31,7 @@ template<typename keyT, template<typename> typename hashT> class AllocStringStor
|
|||
*
|
||||
* \return `true` if the \a key is found in storage, false otherwise.
|
||||
*/
|
||||
bool contains(keyT &key)
|
||||
bool contains(const keyT &key)
|
||||
{
|
||||
return storage_.count(key) != 0;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ template<typename keyT, template<typename> typename hashT> class AllocStringStor
|
|||
*
|
||||
* \return A pointer to the stored string if \a key is found, `nullptr` otherwise.
|
||||
*/
|
||||
const char *find(keyT &key)
|
||||
const char *find(const keyT &key)
|
||||
{
|
||||
if (storage_.count(key) != 0) {
|
||||
return storage_[key].c_str();
|
||||
|
@ -56,7 +56,7 @@ template<typename keyT, template<typename> typename hashT> class AllocStringStor
|
|||
* \param alloc_string: The alloc string to store at \a key.
|
||||
* \return A pointer to the inserted stored string.
|
||||
*/
|
||||
const char *insert(keyT &key, std::string alloc_string)
|
||||
const char *insert(const keyT &key, std::string alloc_string)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert(storage_.count(key) == 0);
|
||||
|
|
|
@ -210,7 +210,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
|
|||
|
||||
/* Upload each tile one by one. */
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
ImageTile_Runtime *tile_runtime = &tile->runtime;
|
||||
const ImageTile_Runtime *tile_runtime = &tile->runtime;
|
||||
const int tilelayer = tile_runtime->tilearray_layer;
|
||||
const int *tileoffset = tile_runtime->tilearray_offset;
|
||||
const int *tilesize = tile_runtime->tilearray_size;
|
||||
|
|
|
@ -295,10 +295,10 @@ void VolumeProbeModule::set_view(View & /*view*/)
|
|||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ;
|
||||
int3 grid_size = int3(cache->size);
|
||||
if (cache->baking.L0) {
|
||||
irradiance_a_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_c);
|
||||
irradiance_a_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_c);
|
||||
validity_tx.ensure_3d(GPU_R16F, grid_size, usage, cache->baking.validity);
|
||||
if (cache->baking.validity == nullptr) {
|
||||
/* Avoid displaying garbage data. */
|
||||
|
@ -306,10 +306,13 @@ void VolumeProbeModule::set_view(View & /*view*/)
|
|||
}
|
||||
}
|
||||
else if (cache->irradiance.L0) {
|
||||
irradiance_a_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_c);
|
||||
irradiance_a_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L0);
|
||||
irradiance_b_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_a);
|
||||
irradiance_c_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_b);
|
||||
irradiance_d_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_c);
|
||||
validity_tx.ensure_3d(GPU_R8, grid_size, usage);
|
||||
if (cache->connectivity.validity) {
|
||||
/* TODO(fclem): Make texture creation API work with different data types. */
|
||||
|
@ -333,7 +336,7 @@ void VolumeProbeModule::set_view(View & /*view*/)
|
|||
if (irradiance_a_tx.is_valid() == false) {
|
||||
inst_.info += "Error: Could not allocate irradiance staging texture\n";
|
||||
/* Avoid undefined behavior with uninitialized values. Still load a clear texture. */
|
||||
float4 zero(0.0f);
|
||||
const float4 zero(0.0f);
|
||||
irradiance_a_tx.ensure_3d(GPU_RGB16F, int3(1), usage, zero);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGB16F, int3(1), usage, zero);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGB16F, int3(1), usage, zero);
|
||||
|
@ -349,10 +352,10 @@ void VolumeProbeModule::set_view(View & /*view*/)
|
|||
draw::Texture visibility_c_tx = {"visibility_c_tx"};
|
||||
draw::Texture visibility_d_tx = {"visibility_d_tx"};
|
||||
if (visibility_available) {
|
||||
visibility_a_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)cache->visibility.L0);
|
||||
visibility_b_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)cache->visibility.L1_a);
|
||||
visibility_c_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)cache->visibility.L1_b);
|
||||
visibility_d_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)cache->visibility.L1_c);
|
||||
visibility_a_tx.ensure_3d(GPU_R16F, grid_size, usage, (const float *)cache->visibility.L0);
|
||||
visibility_b_tx.ensure_3d(GPU_R16F, grid_size, usage, (const float *)cache->visibility.L1_a);
|
||||
visibility_c_tx.ensure_3d(GPU_R16F, grid_size, usage, (const float *)cache->visibility.L1_b);
|
||||
visibility_d_tx.ensure_3d(GPU_R16F, grid_size, usage, (const float *)cache->visibility.L1_c);
|
||||
|
||||
GPU_texture_swizzle_set(visibility_a_tx, "111r");
|
||||
GPU_texture_swizzle_set(visibility_b_tx, "111r");
|
||||
|
@ -506,10 +509,10 @@ void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb)
|
|||
Texture debug_data_tx = {"debug_data_tx"};
|
||||
|
||||
if (inst_.debug_mode == eDebugMode::DEBUG_IRRADIANCE_CACHE_VALIDITY) {
|
||||
float *data;
|
||||
const float *data;
|
||||
if (cache->baking.validity) {
|
||||
data = (float *)cache->baking.validity;
|
||||
debug_data_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)data);
|
||||
data = cache->baking.validity;
|
||||
debug_data_tx.ensure_3d(GPU_R16F, grid_size, usage, data);
|
||||
}
|
||||
else if (cache->connectivity.validity) {
|
||||
debug_data_tx.ensure_3d(GPU_R8, grid_size, usage);
|
||||
|
@ -531,7 +534,7 @@ void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb)
|
|||
}
|
||||
else {
|
||||
if (cache->baking.virtual_offset) {
|
||||
float *data = (float *)cache->baking.virtual_offset;
|
||||
const float *data = (const float *)cache->baking.virtual_offset;
|
||||
debug_data_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, data);
|
||||
}
|
||||
else {
|
||||
|
@ -577,21 +580,24 @@ void VolumeProbeModule::display_pass_draw(View &view, GPUFrameBuffer *view_fb)
|
|||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ;
|
||||
int3 grid_size = int3(cache->size);
|
||||
if (cache->baking.L0) {
|
||||
irradiance_a_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (float *)cache->baking.L1_c);
|
||||
validity_tx.ensure_3d(GPU_R16F, grid_size, usage, (float *)cache->baking.validity);
|
||||
irradiance_a_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGBA16F, grid_size, usage, (const float *)cache->baking.L1_c);
|
||||
validity_tx.ensure_3d(GPU_R16F, grid_size, usage, (const float *)cache->baking.validity);
|
||||
if (cache->baking.validity == nullptr) {
|
||||
/* Avoid displaying garbage data. */
|
||||
validity_tx.clear(float4(0.0));
|
||||
}
|
||||
}
|
||||
else if (cache->irradiance.L0) {
|
||||
irradiance_a_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L0);
|
||||
irradiance_b_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_a);
|
||||
irradiance_c_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_b);
|
||||
irradiance_d_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (float *)cache->irradiance.L1_c);
|
||||
irradiance_a_tx.ensure_3d(GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L0);
|
||||
irradiance_b_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_a);
|
||||
irradiance_c_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_b);
|
||||
irradiance_d_tx.ensure_3d(
|
||||
GPU_RGB16F, grid_size, usage, (const float *)cache->irradiance.L1_c);
|
||||
validity_tx.ensure_3d(GPU_R8, grid_size, usage);
|
||||
if (cache->connectivity.validity) {
|
||||
/* TODO(fclem): Make texture creation API work with different data types. */
|
||||
|
|
|
@ -539,7 +539,7 @@ class Texture : NonCopyable {
|
|||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
int extent,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
bool cubemap = false,
|
||||
int mip_len = 1)
|
||||
: name_(name)
|
||||
|
@ -552,7 +552,7 @@ class Texture : NonCopyable {
|
|||
eGPUTextureUsage usage,
|
||||
int extent,
|
||||
int layers,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
bool cubemap = false,
|
||||
int mip_len = 1)
|
||||
: name_(name)
|
||||
|
@ -564,7 +564,7 @@ class Texture : NonCopyable {
|
|||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
int2 extent,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
: name_(name)
|
||||
{
|
||||
|
@ -576,7 +576,7 @@ class Texture : NonCopyable {
|
|||
eGPUTextureUsage usage,
|
||||
int2 extent,
|
||||
int layers,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
: name_(name)
|
||||
{
|
||||
|
@ -587,7 +587,7 @@ class Texture : NonCopyable {
|
|||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
int3 extent,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
: name_(name)
|
||||
{
|
||||
|
@ -653,7 +653,7 @@ class Texture : NonCopyable {
|
|||
bool ensure_1d(eGPUTextureFormat format,
|
||||
int extent,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
return ensure_impl(extent, 0, 0, mip_len, format, usage, data, false, false);
|
||||
|
@ -667,7 +667,7 @@ class Texture : NonCopyable {
|
|||
int extent,
|
||||
int layers,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
BLI_assert(layers > 0);
|
||||
|
@ -681,7 +681,7 @@ class Texture : NonCopyable {
|
|||
bool ensure_2d(eGPUTextureFormat format,
|
||||
int2 extent,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
return ensure_impl(UNPACK2(extent), 0, mip_len, format, usage, data, false, false);
|
||||
|
@ -695,7 +695,7 @@ class Texture : NonCopyable {
|
|||
int2 extent,
|
||||
int layers,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
BLI_assert(layers > 0);
|
||||
|
@ -709,7 +709,7 @@ class Texture : NonCopyable {
|
|||
bool ensure_3d(eGPUTextureFormat format,
|
||||
int3 extent,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
return ensure_impl(UNPACK3(extent), mip_len, format, usage, data, false, false);
|
||||
|
@ -736,7 +736,7 @@ class Texture : NonCopyable {
|
|||
int extent,
|
||||
int layers,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
int mip_len = 1)
|
||||
{
|
||||
return ensure_impl(extent, extent, layers, mip_len, format, usage, data, true, true);
|
||||
|
@ -995,7 +995,7 @@ class Texture : NonCopyable {
|
|||
int mip_len = 1,
|
||||
eGPUTextureFormat format = GPU_RGBA8,
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL,
|
||||
float *data = nullptr,
|
||||
const float *data = nullptr,
|
||||
bool layered = false,
|
||||
bool cubemap = false)
|
||||
|
||||
|
@ -1116,13 +1116,15 @@ class TextureFromPool : public Texture, NonMovable {
|
|||
}
|
||||
|
||||
/** Remove methods that are forbidden with this type of textures. */
|
||||
bool ensure_1d(int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_1d_array(int, int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_1d(int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) = delete;
|
||||
bool ensure_1d_array(int, int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) = delete;
|
||||
bool ensure_2d(int, int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_2d_array(int, int, int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_3d(int, int, int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_cube(int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_cube_array(int, int, int, eGPUTextureFormat, eGPUTextureUsage, float *) = delete;
|
||||
bool ensure_2d_array(int, int, int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) =
|
||||
delete;
|
||||
bool ensure_3d(int, int, int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) = delete;
|
||||
bool ensure_cube(int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) = delete;
|
||||
bool ensure_cube_array(int, int, int, eGPUTextureFormat, eGPUTextureUsage, const float *) =
|
||||
delete;
|
||||
void filter_mode(bool) = delete;
|
||||
void free() = delete;
|
||||
GPUTexture *mip_view(int) = delete;
|
||||
|
@ -1145,13 +1147,13 @@ class TextureRef : public Texture {
|
|||
}
|
||||
|
||||
/** Remove methods that are forbidden with this type of textures. */
|
||||
bool ensure_1d(int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_1d_array(int, int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_2d(int, int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_2d_array(int, int, int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_3d(int, int, int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_cube(int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_cube_array(int, int, int, eGPUTextureFormat, float *) = delete;
|
||||
bool ensure_1d(int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_1d_array(int, int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_2d(int, int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_2d_array(int, int, int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_3d(int, int, int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_cube(int, int, eGPUTextureFormat, const float *) = delete;
|
||||
bool ensure_cube_array(int, int, int, eGPUTextureFormat, const float *) = delete;
|
||||
void filter_mode(bool) = delete;
|
||||
void free() = delete;
|
||||
GPUTexture *mip_view(int) = delete;
|
||||
|
|
|
@ -970,7 +970,7 @@ std::string GLShader::workaround_geometry_shader_source_create(
|
|||
ss << " gpu_pos[2] = gl_in[2].gl_Position;\n";
|
||||
}
|
||||
for (auto i : IndexRange(3)) {
|
||||
for (StageInterfaceInfo *iface : info_modified.vertex_out_interfaces_) {
|
||||
for (const StageInterfaceInfo *iface : info_modified.vertex_out_interfaces_) {
|
||||
for (auto &inout : iface->inouts) {
|
||||
ss << " " << iface->instance_name << "_out." << inout.name;
|
||||
ss << " = " << iface->instance_name << "_in[" << i << "]." << inout.name << ";\n";
|
||||
|
|
|
@ -1730,7 +1730,7 @@ int DNA_struct_alignment(const SDNA *sdna, const int struct_nr)
|
|||
const char *DNA_struct_identifier(struct SDNA *sdna, const int struct_index)
|
||||
{
|
||||
DNA_sdna_alias_data_ensure(sdna);
|
||||
SDNA_Struct *struct_info = sdna->structs[struct_index];
|
||||
const SDNA_Struct *struct_info = sdna->structs[struct_index];
|
||||
return sdna->alias.types[struct_info->type];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue