36 BitVector<> chunks(chunks_size.x * chunks_size.y,
false);
38 if (c.layer !=
layer) {
41 const rcti &r = c.rect;
42 for (
int ty = r.
ymin / chunk_size; ty <= (r.
ymax - 1) / chunk_size; ty++) {
43 for (
int tx = r.
xmin / chunk_size; tx <= (r.
xmax - 1) / chunk_size; tx++) {
44 chunks[
int64_t(ty) * chunks_size.x + tx].set();
57 return float4(
v.x,
v.y,
v.z,
v.w) * (1.0f / 255.0f);
65 const Span<T> layer_backgrounds,
66 const T changed_value,
69 const float background_threshold)
74 <<
"mipmap compute shader failed to compile";
78 while ((size >> mip_len) > 0) {
81 const int layers = int(layer_backgrounds.
size());
88 "test_mipmap", size, size, layers, mip_len, format, usage,
nullptr);
91 const int64_t layer_len = size * size;
103 for (
int mip = 1; mip < mip_len; mip++) {
104 const int mip_size = size >> mip;
106 float max_diff = 0.0f;
109 for (
int64_t i = 0; i < mip_size * mip_size; i++) {
114 EXPECT_LT(max_diff, 0.02f) <<
"mip level " << mip
115 <<
" of a constant image deviates from the background";
124 patch.
fill(changed_value);
126 texture, data_format, patch.
data(), c.rect.xmin, c.rect.ymin, c.layer,
w, h, 1);
133 const int2 chunks_size(chunks_len, chunks_len);
142 for (
int mip = 1; mip < mip_len; mip++) {
143 const int mip_size = size >> mip;
152 for (
int mip = 1; mip < mip_len; mip++) {
153 const int mip_size = size >> mip;
156 for (
int64_t i = 0; i < mip_size * mip_size * layers; i++) {
157 if (partial[mip][i] !=
data[i]) {
161 EXPECT_EQ(mismatches, 0) <<
"mip level " << mip <<
" differs between partial and full update";
172 <<
"coarsest mip of layer " <<
layer <<
" is not close to the background";
182 {{0, {37, 87, 41, 87}}, {0, {300, 344, 320, 359}}, {0, {256, 281, 256, 281}}}};
190 {
float4(0.1f, 0.4f, 0.7f, 1.0f)},
191 float4(0.9f, 0.2f, 0.5f, 1.0f),
204 {
float4(0.1f, 0.4f, 0.7f, 1.0f)},
205 float4(0.9f, 0.2f, 0.5f, 1.0f),
218 {
uchar4(30, 110, 200, 255)},
219 uchar4(230, 50, 130, 255),
232 {
float4(0.1f, 0.3f, 0.6f, 1.0f),
233 float4(0.2f, 0.3f, 0.6f, 1.0f),
234 float4(0.3f, 0.3f, 0.6f, 1.0f)},
235 float4(0.9f, 0.2f, 0.5f, 1.0f),
237 {{0, {37, 87, 41, 87}}, {2, {300, 344, 320, 359}}},
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
MutableSpan< T > as_mutable_span()
Array(Allocator allocator={}) noexcept
void fill(const T &value) const
constexpr int64_t size() const
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
#define EXPECT_LT(result, expect)
#define EXPECT_NE(result, expect)
#define GPU_TEST(test_name)
static void test_mipmap_partial_float_pow2()
static void test_mipmap_partial_npot()
static void test_mipmap_partial_srgb_pow2()
static void test_mipmap_partial_layered()
static BitVector modified_chunks_bitmask(const int2 chunks_size, const Span< ChangedRegion > changed, const int layer)
static const std::array< ChangedRegion, 3 > test_changed_regions
static float4 to_float4(const float4 &v)
static void test_mipmap_partial_matches_full(const TextureFormat format, const eGPUDataFormat data_format, const eGPUTextureUsage extra_usage, const GPUBuiltinShader mipmap_shader, const Span< T > layer_backgrounds, const T changed_value, const int size, const Span< ChangedRegion > changed, const float background_threshold)
T reduce_max(const VecBase< T, Size > &a)
T max(const T &a, const T &b)
VecBase< uint8_t, 4 > uchar4
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_update_mipmap_chain(gpu::Texture *texture)
constexpr int GPU_TEXTURE_MIPMAP_UPDATE_CHUNK_SIZE
gpu::Texture * GPU_texture_create_2d_array(const char *name, int width, int height, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void GPU_texture_update_sub(gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
void GPU_memory_barrier(GPUBarrier barrier)
BMesh const char void * data
@ GPU_SHADER_2D_UPDATE_MIPMAPS_SFLOAT_32_32_32_32_LAYERED
@ GPU_SHADER_2D_UPDATE_MIPMAPS_SRGBA_8_8_8_8
@ GPU_SHADER_2D_UPDATE_MIPMAPS_SFLOAT_32_32_32_32
void GPU_texture_update_mipmap_chain_partial(gpu::Texture *texture, int layer, BitSpan modified_chunks)
@ GPU_BARRIER_TEXTURE_UPDATE
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
void GPU_texture_free(gpu::Texture *texture)
void * GPU_texture_read(gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)