From 33b25b6a9e86082a40a24b14bb0a6aad708dfb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 8 Sep 2020 03:22:35 +0200 Subject: GPUTexture: Remove unused functions and avoid GPU_texture_opengl_bindcode This is a cleanup. --- source/blender/gpu/GPU_texture.h | 5 ----- source/blender/gpu/intern/gpu_framebuffer.cc | 5 ----- source/blender/gpu/intern/gpu_texture.cc | 25 ++++-------------------- source/blender/gpu/intern/gpu_texture_private.hh | 14 +++++++++++++ source/blender/gpu/opengl/gl_framebuffer.cc | 4 ++-- source/blender/gpu/opengl/gl_texture.hh | 1 + 6 files changed, 21 insertions(+), 33 deletions(-) diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index b31cb42d38d..f2ddb5d8a22 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -233,10 +233,6 @@ void GPU_unpack_row_length_set(uint len); void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat data_format, int miplvl); void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data); -void GPU_invalid_tex_init(void); -void GPU_invalid_tex_bind(int mode); -void GPU_invalid_tex_free(void); - void GPU_texture_free(GPUTexture *tex); void GPU_texture_ref(GPUTexture *tex); @@ -262,7 +258,6 @@ int GPU_texture_orig_width(const GPUTexture *tex); int GPU_texture_orig_height(const GPUTexture *tex); void GPU_texture_orig_size_set(GPUTexture *tex, int w, int h); eGPUTextureFormat GPU_texture_format(const GPUTexture *tex); -int GPU_texture_samples(const GPUTexture *tex); bool GPU_texture_array(const GPUTexture *tex); bool GPU_texture_cube(const GPUTexture *tex); bool GPU_texture_depth(const GPUTexture *tex); diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index f9caa8df143..05cc8a30a43 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -455,11 +455,6 @@ void GPU_framebuffer_blit(GPUFrameBuffer *gpufb_read, BLI_assert(GPU_texture_stencil(read_tex) && GPU_texture_stencil(write_tex)); BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex)); } - if (GPU_texture_samples(write_tex) != 0 || GPU_texture_samples(read_tex) != 0) { - /* Can only blit multisample textures to another texture of the same size. */ - BLI_assert((GPU_texture_width(write_tex) == GPU_texture_width(read_tex)) && - (GPU_texture_height(write_tex) == GPU_texture_height(read_tex))); - } #endif fb_read->blit_to(blit_buffers, read_slot, fb_write, write_slot, 0, 0); diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 95f922173b5..05b97129f00 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -190,7 +190,7 @@ uint GPU_texture_memory_usage_get(void) return 0; } -/* ------ Texture Creation ------ */ +/* ------ Creation ------ */ static inline GPUTexture *gpu_texture_create(const char *name, const int w, @@ -329,6 +329,8 @@ GPUTexture *GPU_texture_create_error(int dimension, bool is_array) return gpu_texture_create("invalid_tex", w, h, d, type, 1, GPU_RGBA8, pixel); } +/* ------ Update ------ */ + void GPU_texture_update_mipmap(GPUTexture *tex_, int miplvl, eGPUDataFormat data_format, @@ -387,20 +389,7 @@ void GPU_unpack_row_length_set(uint len) GPU_context_active_get()->state_manager->texture_unpack_row_length_set(len); } -void GPU_invalid_tex_init(void) -{ - /* TODO remove */ -} - -void GPU_invalid_tex_bind(int UNUSED(mode)) -{ - /* TODO remove */ -} - -void GPU_invalid_tex_free(void) -{ - /* TODO remove */ -} +/* ------ Binding ------ */ void GPU_texture_bind_ex(GPUTexture *tex_, eGPUSamplerState state, @@ -547,12 +536,6 @@ eGPUTextureFormat GPU_texture_format(const GPUTexture *tex) return reinterpret_cast(tex)->format_get(); } -/* TODO remove */ -int GPU_texture_samples(const GPUTexture *UNUSED(tex)) -{ - return 0; -} - bool GPU_texture_depth(const GPUTexture *tex) { return (reinterpret_cast(tex)->format_flag_get() & GPU_FORMAT_DEPTH) != 0; diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh index d237540f654..19022b228b2 100644 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@ -241,6 +241,20 @@ class Texture { virtual bool init_internal(GPUVertBuf *vbo) = 0; }; +/* Syntacting suggar. */ +static inline GPUTexture *wrap(Texture *vert) +{ + return reinterpret_cast(vert); +} +static inline Texture *unwrap(GPUTexture *vert) +{ + return reinterpret_cast(vert); +} +static inline const Texture *unwrap(const GPUTexture *vert) +{ + return reinterpret_cast(vert); +} + #undef DEBUG_NAME_LEN inline size_t to_bytesize(eGPUTextureFormat format) diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index d0644b356ac..61270fe0acc 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -187,7 +187,7 @@ void GLFrameBuffer::update_attachments(void) glFramebufferTexture(GL_FRAMEBUFFER, gl_attachment, 0, 0); continue; } - GLuint gl_tex = GPU_texture_opengl_bindcode(attach.tex); + GLuint gl_tex = static_cast(unwrap(attach.tex))->tex_id_; if (attach.layer > -1 && GPU_texture_cube(attach.tex) && !GPU_texture_array(attach.tex)) { /* Could be avoided if ARB_direct_state_access is required. In this case * #glFramebufferTextureLayer would bind the correct face. */ @@ -216,7 +216,7 @@ void GLFrameBuffer::update_attachments(void) GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0 + i; GPUAttachment &attach = attachments_[type]; if (attach.tex != NULL) { - gl_tex = GPU_texture_opengl_bindcode(attach.tex); + gl_tex = static_cast(unwrap(attach.tex))->tex_id_; } else if (gl_tex != 0) { GLenum gl_attachment = to_gl(type); diff --git a/source/blender/gpu/opengl/gl_texture.hh b/source/blender/gpu/opengl/gl_texture.hh index bdb8a4df4b7..13e546eb879 100644 --- a/source/blender/gpu/opengl/gl_texture.hh +++ b/source/blender/gpu/opengl/gl_texture.hh @@ -46,6 +46,7 @@ namespace gpu { class GLTexture : public Texture { friend class GLStateManager; + friend class GLFrameBuffer; private: /** All samplers states. */ -- cgit v1.2.3