Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/opengl/gl_texture.cc')
-rw-r--r--source/blender/gpu/opengl/gl_texture.cc50
1 files changed, 34 insertions, 16 deletions
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index 6cff97215e8..ec08b736af2 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -25,7 +25,7 @@
#include "DNA_userdef_types.h"
-#include "GPU_extensions.h"
+#include "GPU_capabilities.h"
#include "GPU_framebuffer.h"
#include "GPU_platform.h"
@@ -44,7 +44,7 @@ namespace blender::gpu {
GLTexture::GLTexture(const char *name) : Texture(name)
{
- BLI_assert(GPU_context_active_get() != NULL);
+ BLI_assert(GLContext::get() != NULL);
glGenTextures(1, &tex_id_);
}
@@ -54,12 +54,12 @@ GLTexture::~GLTexture()
if (framebuffer_) {
GPU_framebuffer_free(framebuffer_);
}
- GPUContext *ctx = GPU_context_active_get();
+ GLContext *ctx = GLContext::get();
if (ctx != NULL && is_bound_) {
/* This avoid errors when the texture is still inside the bound texture array. */
ctx->state_manager->texture_unbind(this);
}
- GLBackend::get()->tex_free(tex_id_);
+ GLContext::tex_free(tex_id_);
}
/* Return true on success. */
@@ -71,8 +71,9 @@ bool GLTexture::init_internal(void)
format_ = GPU_DEPTH32F_STENCIL8;
}
- if ((type_ == GPU_TEXTURE_CUBE_ARRAY) && !GPU_arb_texture_cube_map_array_is_supported()) {
- debug::raise_gl_error("Attempt to create a cubemap array without hardware support!");
+ if ((type_ == GPU_TEXTURE_CUBE_ARRAY) && (GLContext::texture_cube_map_array_support == false)) {
+ /* Silently fail and let the caller handle the error. */
+ // debug::raise_gl_error("Attempt to create a cubemap array without hardware support!");
return false;
}
@@ -95,14 +96,12 @@ bool GLTexture::init_internal(void)
glTexParameteri(target_, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
-#ifndef __APPLE__
- if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+ if (GLContext::debug_layer_support) {
char sh_name[64];
SNPRINTF(sh_name, "Texture-%s", name_);
/* Binding before setting the label is needed on some drivers. */
glObjectLabel(GL_TEXTURE, tex_id_, -1, sh_name);
}
-#endif
GL_CHECK_ERROR("Post-texture creation");
return true;
@@ -126,14 +125,12 @@ bool GLTexture::init_internal(GPUVertBuf *vbo)
glTexBuffer(target_, internal_format, gl_vbo->vbo_id_);
}
-#ifndef __APPLE__
- if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+ if (GLContext::debug_layer_support) {
char sh_name[64];
SNPRINTF(sh_name, "Texture-%s", name_);
/* Binding before setting the label is needed on some drivers. */
glObjectLabel(GL_TEXTURE, tex_id_, -1, sh_name);
}
-#endif
GL_CHECK_ERROR("Post-texture buffer creation");
return true;
@@ -369,7 +366,7 @@ void GLTexture::copy_to(Texture *dst_)
/* TODO support array / 3D textures. */
BLI_assert(dst->d_ == 0);
- if (GLEW_ARB_copy_image && !GPU_texture_copy_workaround()) {
+ if (GLEW_ARB_copy_image && !GLContext::texture_copy_workaround) {
/* Opengl 4.3 */
int mip = 0;
/* NOTE: mip_size_get() won't override any dimension that is equal to 0. */
@@ -512,6 +509,23 @@ void GLTexture::samplers_init(void)
* - GL_TEXTURE_MAX_LOD is 1000.
* - GL_TEXTURE_LOD_BIAS is 0.0f.
**/
+
+ if (GLContext::debug_layer_support) {
+ char sampler_name[128];
+ SNPRINTF(sampler_name,
+ "Sampler%s%s%s%s%s%s%s%s%s%s",
+ (state == GPU_SAMPLER_DEFAULT) ? "_default" : "",
+ (state & GPU_SAMPLER_FILTER) ? "_filter" : "",
+ (state & GPU_SAMPLER_MIPMAP) ? "_mipmap" : "",
+ (state & GPU_SAMPLER_REPEAT) ? "_repeat-" : "",
+ (state & GPU_SAMPLER_REPEAT_S) ? "S" : "",
+ (state & GPU_SAMPLER_REPEAT_T) ? "T" : "",
+ (state & GPU_SAMPLER_REPEAT_R) ? "R" : "",
+ (state & GPU_SAMPLER_CLAMP_BORDER) ? "_clamp_border" : "",
+ (state & GPU_SAMPLER_COMPARE) ? "_compare" : "",
+ (state & GPU_SAMPLER_ANISO) ? "_aniso" : "");
+ glObjectLabel(GL_SAMPLER, samplers_[i], -1, sampler_name);
+ }
}
samplers_update();
@@ -520,6 +534,10 @@ void GLTexture::samplers_init(void)
glSamplerParameteri(icon_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glSamplerParameteri(icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameterf(icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f);
+
+ if (GLContext::debug_layer_support) {
+ glObjectLabel(GL_SAMPLER, icon_sampler, -1, "Sampler-icons");
+ }
}
void GLTexture::samplers_update(void)
@@ -560,8 +578,8 @@ bool GLTexture::proxy_check(int mip)
{
/* Manual validation first, since some implementation have issues with proxy creation. */
int max_size = GPU_max_texture_size();
- int max_3d_size = GPU_max_texture_3d_size();
- int max_cube_size = GPU_max_cube_map_size();
+ int max_3d_size = GLContext::max_texture_3d_size;
+ int max_cube_size = GLContext::max_cubemap_size;
int size[3] = {1, 1, 1};
this->mip_size_get(mip, size);
@@ -661,7 +679,7 @@ void GLTexture::check_feedback_loop(void)
if (GPU_mip_render_workaround()) {
return;
}
- GLFrameBuffer *fb = static_cast<GLFrameBuffer *>(GPU_context_active_get()->active_fb);
+ GLFrameBuffer *fb = static_cast<GLFrameBuffer *>(GLContext::get()->active_fb);
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
if (fb_[i] == fb) {
GPUAttachmentType type = fb_attachment_[i];