|
|
@@ -2834,6 +2834,8 @@ reset() {
|
|
|
get_extension_func("glMapNamedBufferRange");
|
|
|
}
|
|
|
|
|
|
+ _glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC)
|
|
|
+ get_extension_func("glNamedBufferSubData");
|
|
|
_glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC)
|
|
|
get_extension_func("glGetNamedBufferSubData");
|
|
|
|
|
|
@@ -7613,6 +7615,9 @@ prepare_shader_buffer(ShaderBuffer *data) {
|
|
|
if (data->get_usage_hint() == GeomEnums::UH_client) {
|
|
|
flags |= GL_CLIENT_STORAGE_BIT;
|
|
|
}
|
|
|
+ if (data->get_usage_hint() == GeomEnums::UH_dynamic) {
|
|
|
+ flags |= GL_DYNAMIC_STORAGE_BIT;
|
|
|
+ }
|
|
|
_glBufferStorage(GL_SHADER_STORAGE_BUFFER, num_bytes, data->get_initial_data(), flags);
|
|
|
} else {
|
|
|
_glBufferData(GL_SHADER_STORAGE_BUFFER, num_bytes, data->get_initial_data(), get_usage(data->get_usage_hint()));
|
|
|
@@ -7761,6 +7766,41 @@ release_shader_buffers(const pvector<BufferContext *> &contexts) {
|
|
|
report_my_gl_errors();
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * This method should only be called by the GraphicsEngine. Do not call it
|
|
|
+ * directly; call GraphicsEngine::update_shader_buffer_data() instead.
|
|
|
+ *
|
|
|
+ * This method will be called in the draw thread to upload data to (a part of)
|
|
|
+ * the shader buffer from the CPU.
|
|
|
+ */
|
|
|
+bool CLP(GraphicsStateGuardian)::
|
|
|
+update_shader_buffer_data(ShaderBuffer *buffer, size_t start, size_t size,
|
|
|
+ const unsigned char *data) {
|
|
|
+ nassertr(buffer->get_usage_hint() == GeomEnums::UH_dynamic, false);
|
|
|
+
|
|
|
+ BufferContext *bc = buffer->prepare_now(get_prepared_objects(), this);
|
|
|
+ if (bc == nullptr || !bc->is_of_type(CLP(BufferContext)::get_class_type())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ CLP(BufferContext) *gbc = DCAST(CLP(BufferContext), bc);
|
|
|
+
|
|
|
+ if (_glMemoryBarrier != nullptr) {
|
|
|
+ _glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_supports_dsa) {
|
|
|
+ _glNamedBufferSubData(gbc->_index, start, size, data);
|
|
|
+ } else {
|
|
|
+ _glBindBuffer(GL_SHADER_STORAGE_BUFFER, gbc->_index);
|
|
|
+ _glBufferSubData(GL_SHADER_STORAGE_BUFFER, start, size, data);
|
|
|
+ _glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
|
|
+ _current_sbuffer_index = 0;
|
|
|
+ }
|
|
|
+ report_my_gl_errors();
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* This method should only be called by the GraphicsEngine. Do not call it
|
|
|
* directly; call GraphicsEngine::extract_texture_data() instead.
|