[Bf-blender-cvs] [a9ef394f6e8] temp-gpu-image-engine: Cleanup: renamed to OneTextureMethod
Jeroen Bakker
noreply at git.blender.org
Wed Dec 8 15:55:52 CET 2021
Commit: a9ef394f6e8545fdf916173bea833cc6da6d2566
Author: Jeroen Bakker
Date: Wed Dec 8 14:30:35 2021 +0100
Branches: temp-gpu-image-engine
https://developer.blender.org/rBa9ef394f6e8545fdf916173bea833cc6da6d2566
Cleanup: renamed to OneTextureMethod
===================================================================
M source/blender/draw/engines/image/image_batches.hh
R095 source/blender/draw/engines/image/image_drawing_mode_one_texture.hh source/blender/draw/engines/image/image_drawing_mode.hh
M source/blender/draw/engines/image/image_engine.cc
M source/blender/draw/engines/image/image_instance_data.hh
M source/blender/draw/engines/image/image_partial_updater.hh
M source/blender/draw/engines/image/image_texture_info.hh
===================================================================
diff --git a/source/blender/draw/engines/image/image_batches.hh b/source/blender/draw/engines/image/image_batches.hh
index c8a99256996..489785d5d12 100644
--- a/source/blender/draw/engines/image/image_batches.hh
+++ b/source/blender/draw/engines/image/image_batches.hh
@@ -26,14 +26,14 @@
/** \brief Create GPUBatch for a IMAGE_ScreenSpaceTextureInfo. */
class BatchUpdater {
- IMAGE_TextureInfo &info;
+ TextureInfo &info;
GPUVertFormat format = {0};
int pos_id;
int uv_id;
public:
- BatchUpdater(IMAGE_TextureInfo &info) : info(info)
+ BatchUpdater(TextureInfo &info) : info(info)
{
}
diff --git a/source/blender/draw/engines/image/image_drawing_mode_one_texture.hh b/source/blender/draw/engines/image/image_drawing_mode.hh
similarity index 95%
rename from source/blender/draw/engines/image/image_drawing_mode_one_texture.hh
rename to source/blender/draw/engines/image/image_drawing_mode.hh
index dd0652fc034..91e74cf76f1 100644
--- a/source/blender/draw/engines/image/image_drawing_mode_one_texture.hh
+++ b/source/blender/draw/engines/image/image_drawing_mode.hh
@@ -22,26 +22,25 @@
#pragma once
+#include "BKE_image_partial_update.hh"
+
+#include "IMB_imbuf_types.h"
+
#include "image_batches.hh"
#include "image_private.hh"
#include "image_wrappers.hh"
-#include "BKE_image_partial_update.hh"
-
namespace blender::draw::image_engine {
constexpr float EPSILON_UV_BOUNDS = 0.00001f;
/**
- * \brief Accessor to texture slots.
- *
- * Texture slots info is stored in IMAGE_PrivateData. The GPUTextures are stored in
- * IMAGE_TextureList. This class simplifies accessing texture slots by providing
+ * \brief Screen space method using a single texture spawning the whole screen.
*/
-struct InstanceDataAccessor {
+struct OneTextureMethod {
IMAGE_InstanceData *instance_data;
- InstanceDataAccessor(IMAGE_InstanceData *instance_data) : instance_data(instance_data)
+ OneTextureMethod(IMAGE_InstanceData *instance_data) : instance_data(instance_data)
{
}
@@ -89,7 +88,7 @@ struct InstanceDataAccessor {
}
}
- void update_uv_to_texture_matrix(IMAGE_TextureInfo *info)
+ void update_uv_to_texture_matrix(TextureInfo *info)
{
// TODO: I remember that there was a function for this somewhere.
unit_m4(info->uv_to_texture);
@@ -107,7 +106,7 @@ struct InstanceDataAccessor {
using namespace blender::bke::image::partial_update;
-class ScreenSpaceDrawingMode : public AbstractDrawingMode {
+template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractDrawingMode {
private:
DRWPass *create_image_pass() const
{
@@ -133,7 +132,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
float image_mat[4][4];
unit_m4(image_mat);
for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) {
- const IMAGE_TextureInfo &info = instance_data->texture_infos[i];
+ const TextureInfo &info = instance_data->texture_infos[i];
if (!info.visible) {
continue;
}
@@ -195,7 +194,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
const float tile_height = static_cast<float>(iterator.tile_data.tile_buffer->y);
for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) {
- const IMAGE_TextureInfo &info = instance_data.texture_infos[i];
+ const TextureInfo &info = instance_data.texture_infos[i];
/* Dirty images will receive a full update. No need to do a partial one now. */
if (info.dirty) {
continue;
@@ -300,7 +299,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
const ImageUser *image_user) const
{
for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) {
- IMAGE_TextureInfo &info = instance_data.texture_infos[i];
+ TextureInfo &info = instance_data.texture_infos[i];
if (!info.dirty) {
continue;
}
@@ -311,7 +310,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
}
}
- void do_full_update_gpu_texture(IMAGE_TextureInfo &info,
+ void do_full_update_gpu_texture(TextureInfo &info,
IMAGE_InstanceData &instance_data,
const ImageUser *image_user) const
{
@@ -340,9 +339,6 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
/**
* \brief Ensure that the float buffer of the given image buffer is available.
- *
- * TODO: Should we add a ImageBufferAccessor for cleaner access.
- * (`image_buffer.ensure_float_buffer()`)
*/
void ensure_float_buffer(ImBuf &image_buffer) const
{
@@ -352,7 +348,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
}
void do_full_update_texture_slot(const IMAGE_InstanceData &instance_data,
- const IMAGE_TextureInfo &texture_info,
+ const TextureInfo &texture_info,
ImBuf &texture_buffer,
ImBuf &tile_buffer,
const ImageTileWrapper &image_tile) const
@@ -412,7 +408,7 @@ class ScreenSpaceDrawingMode : public AbstractDrawingMode {
{
const DRWContextState *draw_ctx = DRW_context_state_get();
IMAGE_InstanceData *instance_data = vedata->instance_data;
- InstanceDataAccessor pda(instance_data);
+ TextureMethod pda(instance_data);
instance_data->partial_update.ensure_image(image);
instance_data->max_uv_update();
diff --git a/source/blender/draw/engines/image/image_engine.cc b/source/blender/draw/engines/image/image_engine.cc
index 112c59d5263..f9000b2c324 100644
--- a/source/blender/draw/engines/image/image_engine.cc
+++ b/source/blender/draw/engines/image/image_engine.cc
@@ -41,7 +41,7 @@
#include "GPU_batch.h"
-#include "image_drawing_mode_one_texture.hh"
+#include "image_drawing_mode.hh"
#include "image_engine.h"
#include "image_private.hh"
#include "image_space_image.hh"
@@ -68,7 +68,7 @@ template<
*
* Useful during development to switch between drawing implementations.
*/
- typename DrawingMode = ScreenSpaceDrawingMode>
+ typename DrawingMode = ScreenSpaceDrawingMode<OneTextureMethod>>
class ImageEngine {
private:
const DRWContextState *draw_ctx;
diff --git a/source/blender/draw/engines/image/image_instance_data.hh b/source/blender/draw/engines/image/image_instance_data.hh
index bc6a776416a..7c4912dc98a 100644
--- a/source/blender/draw/engines/image/image_instance_data.hh
+++ b/source/blender/draw/engines/image/image_instance_data.hh
@@ -59,7 +59,7 @@ struct IMAGE_InstanceData {
bool do_tile_drawing : 1;
} flags;
- IMAGE_TextureInfo texture_infos[SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN];
+ TextureInfo texture_infos[SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN];
/**
* \brief Maximum uv's that are on the border of the image.
@@ -90,7 +90,7 @@ struct IMAGE_InstanceData {
void update_gpu_texture_allocations()
{
for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) {
- IMAGE_TextureInfo &info = texture_infos[i];
+ TextureInfo &info = texture_infos[i];
const bool is_allocated = info.texture != nullptr;
const bool is_visible = info.visible;
const bool should_be_freed = !is_visible && is_allocated;
@@ -112,7 +112,7 @@ struct IMAGE_InstanceData {
void update_batches()
{
for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) {
- IMAGE_TextureInfo &info = texture_infos[i];
+ TextureInfo &info = texture_infos[i];
if (!info.dirty) {
continue;
}
diff --git a/source/blender/draw/engines/image/image_partial_updater.hh b/source/blender/draw/engines/image/image_partial_updater.hh
index 6ef76074a05..f0c1db2331a 100644
--- a/source/blender/draw/engines/image/image_partial_updater.hh
+++ b/source/blender/draw/engines/image/image_partial_updater.hh
@@ -45,6 +45,7 @@ struct PartialImageUpdater {
free();
}
+ private:
/**
* \brief check if the partial update user can still be used for the given image.
*
diff --git a/source/blender/draw/engines/image/image_texture_info.hh b/source/blender/draw/engines/image/image_texture_info.hh
index 770219c7893..759254c301e 100644
--- a/source/blender/draw/engines/image/image_texture_info.hh
+++ b/source/blender/draw/engines/image/image_texture_info.hh
@@ -27,7 +27,7 @@
#include "GPU_batch.h"
#include "GPU_texture.h"
-struct IMAGE_TextureInfo {
+struct TextureInfo {
/**
* \brief Is the texture clipped.
*
@@ -63,7 +63,7 @@ struct IMAGE_TextureInfo {
*/
GPUTexture *texture;
- ~IMAGE_TextureInfo()
+ ~TextureInfo()
{
if (batch != nullptr) {
GPU_batch_discard(batch);
More information about the Bf-blender-cvs
mailing list