Fix build error on mips64el architecture

Same as D12194, name "mips" conflicts on such systems.
This commit is contained in:
Brecht Van Lommel 2022-08-19 17:03:57 +02:00
parent 1608406600
commit 0c8749788c
5 changed files with 68 additions and 61 deletions

View File

@ -392,10 +392,10 @@ class Texture : NonCopyable {
int extent,
float *data = nullptr,
bool cubemap = false,
int mips = 1)
int mip_len = 1)
: name_(name)
{
tx_ = create(extent, 0, 0, mips, format, data, false, cubemap);
tx_ = create(extent, 0, 0, mip_len, format, data, false, cubemap);
}
Texture(const char *name,
@ -404,17 +404,20 @@ class Texture : NonCopyable {
int layers,
float *data = nullptr,
bool cubemap = false,
int mips = 1)
int mip_len = 1)
: name_(name)
{
tx_ = create(extent, layers, 0, mips, format, data, true, cubemap);
tx_ = create(extent, layers, 0, mip_len, format, data, true, cubemap);
}
Texture(
const char *name, eGPUTextureFormat format, int2 extent, float *data = nullptr, int mips = 1)
Texture(const char *name,
eGPUTextureFormat format,
int2 extent,
float *data = nullptr,
int mip_len = 1)
: name_(name)
{
tx_ = create(UNPACK2(extent), 0, mips, format, data, false, false);
tx_ = create(UNPACK2(extent), 0, mip_len, format, data, false, false);
}
Texture(const char *name,
@ -422,17 +425,20 @@ class Texture : NonCopyable {
int2 extent,
int layers,
float *data = nullptr,
int mips = 1)
int mip_len = 1)
: name_(name)
{
tx_ = create(UNPACK2(extent), layers, mips, format, data, true, false);
tx_ = create(UNPACK2(extent), layers, mip_len, format, data, true, false);
}
Texture(
const char *name, eGPUTextureFormat format, int3 extent, float *data = nullptr, int mips = 1)
Texture(const char *name,
eGPUTextureFormat format,
int3 extent,
float *data = nullptr,
int mip_len = 1)
: name_(name)
{
tx_ = create(UNPACK3(extent), mips, format, data, false, false);
tx_ = create(UNPACK3(extent), mip_len, format, data, false, false);
}
~Texture()
@ -467,9 +473,9 @@ class Texture : NonCopyable {
* Ensure the texture has the correct properties. Recreating it if needed.
* Return true if a texture has been created.
*/
bool ensure_1d(eGPUTextureFormat format, int extent, float *data = nullptr, int mips = 1)
bool ensure_1d(eGPUTextureFormat format, int extent, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(extent, 0, 0, mips, format, data, false, false);
return ensure_impl(extent, 0, 0, mip_len, format, data, false, false);
}
/**
@ -477,18 +483,18 @@ class Texture : NonCopyable {
* Return true if a texture has been created.
*/
bool ensure_1d_array(
eGPUTextureFormat format, int extent, int layers, float *data = nullptr, int mips = 1)
eGPUTextureFormat format, int extent, int layers, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(extent, layers, 0, mips, format, data, true, false);
return ensure_impl(extent, layers, 0, mip_len, format, data, true, false);
}
/**
* Ensure the texture has the correct properties. Recreating it if needed.
* Return true if a texture has been created.
*/
bool ensure_2d(eGPUTextureFormat format, int2 extent, float *data = nullptr, int mips = 1)
bool ensure_2d(eGPUTextureFormat format, int2 extent, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(UNPACK2(extent), 0, mips, format, data, false, false);
return ensure_impl(UNPACK2(extent), 0, mip_len, format, data, false, false);
}
/**
@ -496,27 +502,27 @@ class Texture : NonCopyable {
* Return true if a texture has been created.
*/
bool ensure_2d_array(
eGPUTextureFormat format, int2 extent, int layers, float *data = nullptr, int mips = 1)
eGPUTextureFormat format, int2 extent, int layers, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(UNPACK2(extent), layers, mips, format, data, true, false);
return ensure_impl(UNPACK2(extent), layers, mip_len, format, data, true, false);
}
/**
* Ensure the texture has the correct properties. Recreating it if needed.
* Return true if a texture has been created.
*/
bool ensure_3d(eGPUTextureFormat format, int3 extent, float *data = nullptr, int mips = 1)
bool ensure_3d(eGPUTextureFormat format, int3 extent, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(UNPACK3(extent), mips, format, data, false, false);
return ensure_impl(UNPACK3(extent), mip_len, format, data, false, false);
}
/**
* Ensure the texture has the correct properties. Recreating it if needed.
* Return true if a texture has been created.
*/
bool ensure_cube(eGPUTextureFormat format, int extent, float *data = nullptr, int mips = 1)
bool ensure_cube(eGPUTextureFormat format, int extent, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(extent, extent, 0, mips, format, data, false, true);
return ensure_impl(extent, extent, 0, mip_len, format, data, false, true);
}
/**
@ -524,9 +530,9 @@ class Texture : NonCopyable {
* Return true if a texture has been created.
*/
bool ensure_cube_array(
eGPUTextureFormat format, int extent, int layers, float *data = nullptr, int mips = 1)
eGPUTextureFormat format, int extent, int layers, float *data = nullptr, int mip_len = 1)
{
return ensure_impl(extent, extent, layers, mips, format, data, false, true);
return ensure_impl(extent, extent, layers, mip_len, format, data, false, true);
}
/**
@ -709,7 +715,7 @@ class Texture : NonCopyable {
bool ensure_impl(int w,
int h = 0,
int d = 0,
int mips = 1,
int mip_len = 1,
eGPUTextureFormat format = GPU_RGBA8,
float *data = nullptr,
bool layered = false,
@ -726,7 +732,7 @@ class Texture : NonCopyable {
}
}
if (tx_ == nullptr) {
tx_ = create(w, h, d, mips, format, data, layered, cubemap);
tx_ = create(w, h, d, mip_len, format, data, layered, cubemap);
return true;
}
return false;
@ -735,37 +741,37 @@ class Texture : NonCopyable {
GPUTexture *create(int w,
int h,
int d,
int mips,
int mip_len,
eGPUTextureFormat format,
float *data,
bool layered,
bool cubemap)
{
if (h == 0) {
return GPU_texture_create_1d(name_, w, mips, format, data);
return GPU_texture_create_1d(name_, w, mip_len, format, data);
}
else if (cubemap) {
if (layered) {
return GPU_texture_create_cube_array(name_, w, d, mips, format, data);
return GPU_texture_create_cube_array(name_, w, d, mip_len, format, data);
}
else {
return GPU_texture_create_cube(name_, w, mips, format, data);
return GPU_texture_create_cube(name_, w, mip_len, format, data);
}
}
else if (d == 0) {
if (layered) {
return GPU_texture_create_1d_array(name_, w, h, mips, format, data);
return GPU_texture_create_1d_array(name_, w, h, mip_len, format, data);
}
else {
return GPU_texture_create_2d(name_, w, h, mips, format, data);
return GPU_texture_create_2d(name_, w, h, mip_len, format, data);
}
}
else {
if (layered) {
return GPU_texture_create_2d_array(name_, w, h, d, mips, format, data);
return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, data);
}
else {
return GPU_texture_create_3d(name_, w, h, d, mips, format, GPU_DATA_FLOAT, data);
return GPU_texture_create_3d(name_, w, h, d, mip_len, format, GPU_DATA_FLOAT, data);
}
}
}

View File

@ -77,9 +77,10 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
* filtering results. Mipmaps can be used to get better results (i.e. #GL_LINEAR_MIPMAP_LINEAR),
* so always use mipmaps when filtering. */
const bool use_mipmap = use_filter && ((draw_width < img_w) || (draw_height < img_h));
const int mips = use_mipmap ? 9999 : 1;
const int mip_len = use_mipmap ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_2d("immDrawPixels", img_w, img_h, mips, gpu_format, NULL);
GPUTexture *tex = GPU_texture_create_2d(
"immDrawPixels", img_w, img_h, mip_len, gpu_format, NULL);
const bool use_float_data = ELEM(gpu_format, GPU_RGBA16F, GPU_RGB16F, GPU_R16F);
eGPUDataFormat gpu_data_format = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;

View File

@ -193,7 +193,7 @@ unsigned int GPU_texture_memory_usage_get(void);
* \note \a data is expected to be float. If the \a format is not compatible with float data or if
* the data is not in float format, use GPU_texture_update to upload the data with the right data
* format.
* \a mips is the number of mip level to allocate. It must be >= 1.
* \a mip_len is the number of mip level to allocate. It must be >= 1.
*/
GPUTexture *GPU_texture_create_1d(
const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data);

View File

@ -51,13 +51,13 @@ Texture::~Texture()
#endif
}
bool Texture::init_1D(int w, int layers, int mips, eGPUTextureFormat format)
bool Texture::init_1D(int w, int layers, int mip_len, eGPUTextureFormat format)
{
w_ = w;
h_ = layers;
d_ = 0;
int mips_max = 1 + floorf(log2f(w));
mipmaps_ = min_ii(mips, mips_max);
int mip_len_max = 1 + floorf(log2f(w));
mipmaps_ = min_ii(mip_len, mip_len_max);
format_ = format;
format_flag_ = to_format_flag(format);
type_ = (layers > 0) ? GPU_TEXTURE_1D_ARRAY : GPU_TEXTURE_1D;
@ -67,13 +67,13 @@ bool Texture::init_1D(int w, int layers, int mips, eGPUTextureFormat format)
return this->init_internal();
}
bool Texture::init_2D(int w, int h, int layers, int mips, eGPUTextureFormat format)
bool Texture::init_2D(int w, int h, int layers, int mip_len, eGPUTextureFormat format)
{
w_ = w;
h_ = h;
d_ = layers;
int mips_max = 1 + floorf(log2f(max_ii(w, h)));
mipmaps_ = min_ii(mips, mips_max);
int mip_len_max = 1 + floorf(log2f(max_ii(w, h)));
mipmaps_ = min_ii(mip_len, mip_len_max);
format_ = format;
format_flag_ = to_format_flag(format);
type_ = (layers > 0) ? GPU_TEXTURE_2D_ARRAY : GPU_TEXTURE_2D;
@ -83,13 +83,13 @@ bool Texture::init_2D(int w, int h, int layers, int mips, eGPUTextureFormat form
return this->init_internal();
}
bool Texture::init_3D(int w, int h, int d, int mips, eGPUTextureFormat format)
bool Texture::init_3D(int w, int h, int d, int mip_len, eGPUTextureFormat format)
{
w_ = w;
h_ = h;
d_ = d;
int mips_max = 1 + floorf(log2f(max_iii(w, h, d)));
mipmaps_ = min_ii(mips, mips_max);
int mip_len_max = 1 + floorf(log2f(max_iii(w, h, d)));
mipmaps_ = min_ii(mip_len, mip_len_max);
format_ = format;
format_flag_ = to_format_flag(format);
type_ = GPU_TEXTURE_3D;
@ -99,13 +99,13 @@ bool Texture::init_3D(int w, int h, int d, int mips, eGPUTextureFormat format)
return this->init_internal();
}
bool Texture::init_cubemap(int w, int layers, int mips, eGPUTextureFormat format)
bool Texture::init_cubemap(int w, int layers, int mip_len, eGPUTextureFormat format)
{
w_ = w;
h_ = w;
d_ = max_ii(1, layers) * 6;
int mips_max = 1 + floorf(log2f(w));
mipmaps_ = min_ii(mips, mips_max);
int mip_len_max = 1 + floorf(log2f(w));
mipmaps_ = min_ii(mip_len, mip_len_max);
format_ = format;
format_flag_ = to_format_flag(format);
type_ = (layers > 0) ? GPU_TEXTURE_CUBE_ARRAY : GPU_TEXTURE_CUBE;
@ -237,29 +237,29 @@ static inline GPUTexture *gpu_texture_create(const char *name,
const int h,
const int d,
const eGPUTextureType type,
int mips,
int mip_len,
eGPUTextureFormat tex_format,
eGPUDataFormat data_format,
const void *pixels)
{
BLI_assert(mips > 0);
BLI_assert(mip_len > 0);
Texture *tex = GPUBackend::get()->texture_alloc(name);
bool success = false;
switch (type) {
case GPU_TEXTURE_1D:
case GPU_TEXTURE_1D_ARRAY:
success = tex->init_1D(w, h, mips, tex_format);
success = tex->init_1D(w, h, mip_len, tex_format);
break;
case GPU_TEXTURE_2D:
case GPU_TEXTURE_2D_ARRAY:
success = tex->init_2D(w, h, d, mips, tex_format);
success = tex->init_2D(w, h, d, mip_len, tex_format);
break;
case GPU_TEXTURE_3D:
success = tex->init_3D(w, h, d, mips, tex_format);
success = tex->init_3D(w, h, d, mip_len, tex_format);
break;
case GPU_TEXTURE_CUBE:
case GPU_TEXTURE_CUBE_ARRAY:
success = tex->init_cubemap(w, d, mips, tex_format);
success = tex->init_cubemap(w, d, mip_len, tex_format);
break;
default:
break;

View File

@ -101,10 +101,10 @@ class Texture {
virtual ~Texture();
/* Return true on success. */
bool init_1D(int w, int layers, int mips, eGPUTextureFormat format);
bool init_2D(int w, int h, int layers, int mips, eGPUTextureFormat format);
bool init_3D(int w, int h, int d, int mips, eGPUTextureFormat format);
bool init_cubemap(int w, int layers, int mips, eGPUTextureFormat format);
bool init_1D(int w, int layers, int mip_len, eGPUTextureFormat format);
bool init_2D(int w, int h, int layers, int mip_len, eGPUTextureFormat format);
bool init_3D(int w, int h, int d, int mip_len, eGPUTextureFormat format);
bool init_cubemap(int w, int layers, int mip_len, eGPUTextureFormat format);
bool init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format);
bool init_view(const GPUTexture *src,
eGPUTextureFormat format,