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/intern')
-rw-r--r--source/blender/gpu/intern/gpu_capabilities.cc40
-rw-r--r--source/blender/gpu/intern/gpu_capabilities_private.hh9
-rw-r--r--source/blender/gpu/intern/gpu_context.cc2
-rw-r--r--source/blender/gpu/intern/gpu_debug.cc4
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc19
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer_private.hh14
-rw-r--r--source/blender/gpu/intern/gpu_matrix.cc2
-rw-r--r--source/blender/gpu/intern/gpu_platform.cc73
-rw-r--r--source/blender/gpu/intern/gpu_platform_private.hh16
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc2
-rw-r--r--source/blender/gpu/intern/gpu_state.cc6
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc19
-rw-r--r--source/blender/gpu/intern/gpu_texture_private.hh7
13 files changed, 187 insertions, 26 deletions
diff --git a/source/blender/gpu/intern/gpu_capabilities.cc b/source/blender/gpu/intern/gpu_capabilities.cc
index 6d9182dcf17..d8764502800 100644
--- a/source/blender/gpu/intern/gpu_capabilities.cc
+++ b/source/blender/gpu/intern/gpu_capabilities.cc
@@ -82,6 +82,46 @@ int GPU_max_textures(void)
return GCaps.max_textures;
}
+int GPU_max_uniforms_vert(void)
+{
+ return GCaps.max_uniforms_vert;
+}
+
+int GPU_max_uniforms_frag(void)
+{
+ return GCaps.max_uniforms_frag;
+}
+
+int GPU_max_batch_indices(void)
+{
+ return GCaps.max_batch_indices;
+}
+
+int GPU_max_batch_vertices(void)
+{
+ return GCaps.max_batch_vertices;
+}
+
+int GPU_max_vertex_attribs(void)
+{
+ return GCaps.max_vertex_attribs;
+}
+
+int GPU_max_varying_floats(void)
+{
+ return GCaps.max_varying_floats;
+}
+
+int GPU_extensions_len(void)
+{
+ return GCaps.extensions_len;
+}
+
+const char *GPU_extension_get(int i)
+{
+ return GCaps.extension_get ? GCaps.extension_get(i) : "\0";
+}
+
bool GPU_mip_render_workaround(void)
{
return GCaps.mip_render_workaround;
diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh
index 2b3292749f8..7c1d4590ce8 100644
--- a/source/blender/gpu/intern/gpu_capabilities_private.hh
+++ b/source/blender/gpu/intern/gpu_capabilities_private.hh
@@ -41,6 +41,15 @@ struct GPUCapabilities {
int max_textures_vert = 0;
int max_textures_geom = 0;
int max_textures_frag = 0;
+ int max_uniforms_vert = 0;
+ int max_uniforms_frag = 0;
+ int max_batch_indices = 0;
+ int max_batch_vertices = 0;
+ int max_vertex_attribs = 0;
+ int max_varying_floats = 0;
+ int extensions_len = 0;
+ const char *(*extension_get)(int);
+
bool mem_stats_support = false;
bool shader_image_load_store_support = false;
/* OpenGL related workarounds. */
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc
index a9d32dcf297..b5a437b46f7 100644
--- a/source/blender/gpu/intern/gpu_context.cc
+++ b/source/blender/gpu/intern/gpu_context.cc
@@ -24,7 +24,7 @@
* Use these instead of glGenBuffers & its friends
* - alloc must be called from a thread that is bound
* to the context that will be used for drawing with
- * this vao.
+ * this VAO.
* - free can be called from any thread
*/
diff --git a/source/blender/gpu/intern/gpu_debug.cc b/source/blender/gpu/intern/gpu_debug.cc
index 63e7024b74b..2d9fb7822ae 100644
--- a/source/blender/gpu/intern/gpu_debug.cc
+++ b/source/blender/gpu/intern/gpu_debug.cc
@@ -86,8 +86,8 @@ bool GPU_debug_group_match(const char *ref)
if (ctx == nullptr) {
return false;
}
- DebugStack &stack = ctx->debug_stack;
- for (StringRef &name : stack) {
+ const DebugStack &stack = ctx->debug_stack;
+ for (const StringRef &name : stack) {
if (name == ref) {
return true;
}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index 1e3cf479462..1293cc0953d 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -71,6 +71,12 @@ FrameBuffer::~FrameBuffer()
reinterpret_cast<Texture *>(attachment.tex)->detach_from(this);
}
}
+
+#ifndef GPU_NO_USE_PY_REFERENCES
+ if (this->py_ref) {
+ *this->py_ref = nullptr;
+ }
+#endif
}
/** \} */
@@ -473,6 +479,19 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb,
unwrap(gpu_fb)->recursive_downsample(max_lvl, callback, userData);
}
+#ifndef GPU_NO_USE_PY_REFERENCES
+void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb)
+{
+ return unwrap(gpu_fb)->py_ref;
+}
+
+void GPU_framebuffer_py_reference_set(GPUFrameBuffer *gpu_fb, void **py_ref)
+{
+ BLI_assert(py_ref == nullptr || unwrap(gpu_fb)->py_ref == nullptr);
+ unwrap(gpu_fb)->py_ref = py_ref;
+}
+#endif
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/gpu/intern/gpu_framebuffer_private.hh b/source/blender/gpu/intern/gpu_framebuffer_private.hh
index d63d72cf4f7..2b00c239af4 100644
--- a/source/blender/gpu/intern/gpu_framebuffer_private.hh
+++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh
@@ -100,6 +100,20 @@ class FrameBuffer {
bool scissor_test_ = false;
bool dirty_state_ = true;
+#ifndef GPU_NO_USE_PY_REFERENCES
+ public:
+ /**
+ * Reference of a pointer that needs to be cleaned when deallocating the frame-buffer.
+ * Points to #BPyGPUFrameBuffer.fb
+ */
+ void **py_ref = nullptr;
+#endif
+
+ public:
+ /* Reference of a pointer that needs to be cleaned when deallocating the frame-buffer.
+ * Points to #BPyGPUFrameBuffer::fb */
+ void **ref = nullptr;
+
public:
FrameBuffer(const char *name);
virtual ~FrameBuffer();
diff --git a/source/blender/gpu/intern/gpu_matrix.cc b/source/blender/gpu/intern/gpu_matrix.cc
index 2ae50d913da..569b51a407a 100644
--- a/source/blender/gpu/intern/gpu_matrix.cc
+++ b/source/blender/gpu/intern/gpu_matrix.cc
@@ -543,7 +543,7 @@ bool GPU_matrix_unproject_precalc(struct GPUMatrixUnproject_Precalc *precalc,
&precalc->dims.zmax);
if (isinf(precalc->dims.zmax)) {
/* We cannot retrieve the actual value of the clip_end.
- * Use `FLT_MAX` to avoid nans. */
+ * Use `FLT_MAX` to avoid NAN's. */
precalc->dims.zmax = FLT_MAX;
}
for (int i = 0; i < 4; i++) {
diff --git a/source/blender/gpu/intern/gpu_platform.cc b/source/blender/gpu/intern/gpu_platform.cc
index 6b9878f2ba4..49dde473300 100644
--- a/source/blender/gpu/intern/gpu_platform.cc
+++ b/source/blender/gpu/intern/gpu_platform.cc
@@ -41,10 +41,10 @@ namespace blender::gpu {
GPUPlatformGlobal GPG;
-void GPUPlatformGlobal::create_key(eGPUSupportLevel support_level,
- const char *vendor,
- const char *renderer,
- const char *version)
+static char *create_key(eGPUSupportLevel support_level,
+ const char *vendor,
+ const char *renderer,
+ const char *version)
{
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_appendf(ds, "{%s/%s/%s}=", vendor, renderer, version);
@@ -58,29 +58,56 @@ void GPUPlatformGlobal::create_key(eGPUSupportLevel support_level,
BLI_dynstr_append(ds, "UNSUPPORTED");
}
- support_key = BLI_dynstr_get_cstring(ds);
+ char *support_key = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
BLI_str_replace_char(support_key, '\n', ' ');
BLI_str_replace_char(support_key, '\r', ' ');
+ return support_key;
}
-void GPUPlatformGlobal::create_gpu_name(const char *vendor,
- const char *renderer,
- const char *version)
+static char *create_gpu_name(const char *vendor, const char *renderer, const char *version)
{
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_appendf(ds, "%s %s %s", vendor, renderer, version);
- gpu_name = BLI_dynstr_get_cstring(ds);
+ char *gpu_name = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
BLI_str_replace_char(gpu_name, '\n', ' ');
BLI_str_replace_char(gpu_name, '\r', ' ');
+ return gpu_name;
+}
+
+void GPUPlatformGlobal::init(eGPUDeviceType gpu_device,
+ eGPUOSType os_type,
+ eGPUDriverType driver_type,
+ eGPUSupportLevel gpu_support_level,
+ const char *vendor_str,
+ const char *renderer_str,
+ const char *version_str)
+{
+ this->clear();
+
+ this->initialized = true;
+
+ this->device = gpu_device;
+ this->os = os_type;
+ this->driver = driver_type;
+ this->support_level = gpu_support_level;
+
+ this->vendor = BLI_strdup(vendor_str);
+ this->renderer = BLI_strdup(renderer_str);
+ this->version = BLI_strdup(version_str);
+ this->support_key = create_key(gpu_support_level, vendor_str, renderer_str, version_str);
+ this->gpu_name = create_gpu_name(vendor_str, renderer_str, version_str);
}
void GPUPlatformGlobal::clear()
{
- MEM_SAFE_FREE(GPG.support_key);
- MEM_SAFE_FREE(GPG.gpu_name);
+ MEM_SAFE_FREE(vendor);
+ MEM_SAFE_FREE(renderer);
+ MEM_SAFE_FREE(version);
+ MEM_SAFE_FREE(support_key);
+ MEM_SAFE_FREE(gpu_name);
initialized = false;
}
@@ -96,22 +123,44 @@ using namespace blender::gpu;
eGPUSupportLevel GPU_platform_support_level()
{
+ BLI_assert(GPG.initialized);
return GPG.support_level;
}
-const char *GPU_platform_support_level_key()
+const char *GPU_platform_vendor(void)
+{
+ BLI_assert(GPG.initialized);
+ return GPG.vendor;
+}
+
+const char *GPU_platform_renderer(void)
+{
+ BLI_assert(GPG.initialized);
+ return GPG.renderer;
+}
+
+const char *GPU_platform_version(void)
+{
+ BLI_assert(GPG.initialized);
+ return GPG.version;
+}
+
+const char *GPU_platform_support_level_key(void)
{
+ BLI_assert(GPG.initialized);
return GPG.support_key;
}
const char *GPU_platform_gpu_name(void)
{
+ BLI_assert(GPG.initialized);
return GPG.gpu_name;
}
/* GPU Types */
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver)
{
+ BLI_assert(GPG.initialized);
return (GPG.device & device) && (GPG.os & os) && (GPG.driver & driver);
}
diff --git a/source/blender/gpu/intern/gpu_platform_private.hh b/source/blender/gpu/intern/gpu_platform_private.hh
index 02d99efa4a9..f823269ab54 100644
--- a/source/blender/gpu/intern/gpu_platform_private.hh
+++ b/source/blender/gpu/intern/gpu_platform_private.hh
@@ -34,16 +34,20 @@ class GPUPlatformGlobal {
eGPUOSType os;
eGPUDriverType driver;
eGPUSupportLevel support_level;
+ char *vendor = nullptr;
+ char *renderer = nullptr;
+ char *version = nullptr;
char *support_key = nullptr;
char *gpu_name = nullptr;
public:
- void create_key(eGPUSupportLevel support_level,
- const char *vendor,
- const char *renderer,
- const char *version);
-
- void create_gpu_name(const char *vendor, const char *renderer, const char *version);
+ void init(eGPUDeviceType gpu_device,
+ eGPUOSType os_type,
+ eGPUDriverType driver_type,
+ eGPUSupportLevel gpu_support_level,
+ const char *vendor_str,
+ const char *renderer_str,
+ const char *version_str);
void clear(void);
};
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 75fe7652715..aea27756708 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -723,7 +723,7 @@ void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, cons
static int g_shader_builtin_srgb_transform = 0;
static bool g_shader_builtin_srgb_is_dirty = false;
-static bool gpu_shader_srgb_uniform_dirty_get(void)
+static bool gpu_shader_srgb_uniform_dirty_get()
{
return g_shader_builtin_srgb_is_dirty;
}
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index 782d25747bb..5c33066c720 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -248,7 +248,7 @@ eGPUWriteMask GPU_write_mask_get()
uint GPU_stencil_mask_get()
{
- GPUStateMutable &state = Context::get()->state_manager->mutable_state;
+ const GPUStateMutable &state = Context::get()->state_manager->mutable_state;
return state.stencil_write_mask;
}
@@ -267,7 +267,7 @@ eGPUStencilTest GPU_stencil_test_get()
/* NOTE: Already premultiplied by U.pixelsize. */
float GPU_line_width_get()
{
- GPUStateMutable &state = Context::get()->state_manager->mutable_state;
+ const GPUStateMutable &state = Context::get()->state_manager->mutable_state;
return state.line_width;
}
@@ -292,7 +292,7 @@ void GPU_viewport_size_get_i(int coords[4])
bool GPU_depth_mask_get()
{
- GPUState &state = Context::get()->state_manager->state;
+ const GPUState &state = Context::get()->state_manager->state;
return (state.write_mask & GPU_WRITE_DEPTH) != 0;
}
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index c3e9058c6c7..997064e82a2 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -60,6 +60,12 @@ Texture::~Texture()
fb_[i]->attachment_remove(fb_attachment_[i]);
}
}
+
+#ifndef GPU_NO_USE_PY_REFERENCES
+ if (this->py_ref) {
+ *this->py_ref = nullptr;
+ }
+#endif
}
bool Texture::init_1D(int w, int layers, eGPUTextureFormat format)
@@ -581,6 +587,19 @@ bool GPU_texture_array(const GPUTexture *tex)
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_ARRAY) != 0;
}
+#ifndef GPU_NO_USE_PY_REFERENCES
+void **GPU_texture_py_reference_get(GPUTexture *tex)
+{
+ return unwrap(tex)->py_ref;
+}
+
+void GPU_texture_py_reference_set(GPUTexture *tex, void **py_ref)
+{
+ BLI_assert(py_ref == nullptr || unwrap(tex)->py_ref == nullptr);
+ unwrap(tex)->py_ref = py_ref;
+}
+#endif
+
/* TODO remove */
int GPU_texture_opengl_bindcode(const GPUTexture *tex)
{
diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh
index 3d808bce152..a8f2e482bdd 100644
--- a/source/blender/gpu/intern/gpu_texture_private.hh
+++ b/source/blender/gpu/intern/gpu_texture_private.hh
@@ -80,6 +80,13 @@ class Texture {
int refcount = 1;
/** Width & Height (of source data), optional. */
int src_w = 0, src_h = 0;
+#ifndef GPU_NO_USE_PY_REFERENCES
+ /**
+ * Reference of a pointer that needs to be cleaned when deallocating the texture.
+ * Points to #BPyGPUTexture.tex
+ */
+ void **py_ref = nullptr;
+#endif
protected:
/* ---- Texture format (immutable after init). ---- */