GPU: Remove wrapper type for gpu::StorageBuf
This is the first step into merging DRW_gpu_wrapper.hh into the GPU module. This is very similar to #119825. Pull Request: https://projects.blender.org/blender/blender/pulls/144329
This commit is contained in:
committed by
Clément Foucault
parent
6dca66d606
commit
7a97105b28
@@ -76,17 +76,17 @@ class EvalOutputAPI::EvalOutput {
|
||||
// data structure. They need to be overridden in the specific instances of the EvalOutput derived
|
||||
// classes if needed, while the interfaces above are overridden through VolatileEvalOutput.
|
||||
|
||||
virtual GPUStorageBuf *create_patch_arrays_buf()
|
||||
virtual gpu::StorageBuf *create_patch_arrays_buf()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual GPUStorageBuf *get_patch_index_buf()
|
||||
virtual gpu::StorageBuf *get_patch_index_buf()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual GPUStorageBuf *get_patch_param_buf()
|
||||
virtual gpu::StorageBuf *get_patch_param_buf()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -101,17 +101,17 @@ class EvalOutputAPI::EvalOutput {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual GPUStorageBuf *create_face_varying_patch_array_buf(const int /*face_varying_channel*/)
|
||||
virtual gpu::StorageBuf *create_face_varying_patch_array_buf(const int /*face_varying_channel*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual GPUStorageBuf *get_face_varying_patch_index_buf(const int /*face_varying_channel*/)
|
||||
virtual gpu::StorageBuf *get_face_varying_patch_index_buf(const int /*face_varying_channel*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual GPUStorageBuf *get_face_varying_patch_param_buf(const int /*face_varying_channel*/)
|
||||
virtual gpu::StorageBuf *get_face_varying_patch_param_buf(const int /*face_varying_channel*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ using OpenSubdiv::Osd::PatchArrayVector;
|
||||
|
||||
namespace blender::opensubdiv {
|
||||
|
||||
static GPUStorageBuf *create_patch_array_buffer(const PatchArrayVector &patch_arrays)
|
||||
static gpu::StorageBuf *create_patch_array_buffer(const PatchArrayVector &patch_arrays)
|
||||
{
|
||||
const size_t patch_array_size = sizeof(PatchArray);
|
||||
const size_t patch_array_byte_size = patch_array_size * patch_arrays.size();
|
||||
GPUStorageBuf *storage_buf = GPU_storagebuf_create_ex(
|
||||
gpu::StorageBuf *storage_buf = GPU_storagebuf_create_ex(
|
||||
patch_array_byte_size, patch_arrays.data(), GPU_USAGE_STATIC, "osd_patch_array");
|
||||
return storage_buf;
|
||||
}
|
||||
@@ -43,13 +43,13 @@ GpuEvalOutput::GpuEvalOutput(const StencilTable *vertex_stencils,
|
||||
{
|
||||
}
|
||||
|
||||
GPUStorageBuf *GpuEvalOutput::create_patch_arrays_buf()
|
||||
gpu::StorageBuf *GpuEvalOutput::create_patch_arrays_buf()
|
||||
{
|
||||
GPUPatchTable *patch_table = getPatchTable();
|
||||
return create_patch_array_buffer(patch_table->GetPatchArrays());
|
||||
}
|
||||
|
||||
GPUStorageBuf *GpuEvalOutput::create_face_varying_patch_array_buf(const int face_varying_channel)
|
||||
gpu::StorageBuf *GpuEvalOutput::create_face_varying_patch_array_buf(const int face_varying_channel)
|
||||
{
|
||||
GPUPatchTable *patch_table = getFVarPatchTable(face_varying_channel);
|
||||
return create_patch_array_buffer(patch_table->GetFVarPatchArrays(face_varying_channel));
|
||||
|
||||
@@ -31,14 +31,14 @@ class GpuEvalOutput : public VolatileEvalOutput<GPUVertexBuffer,
|
||||
const PatchTable *patch_table,
|
||||
EvaluatorCache *evaluator_cache = nullptr);
|
||||
|
||||
GPUStorageBuf *create_patch_arrays_buf() override;
|
||||
gpu::StorageBuf *create_patch_arrays_buf() override;
|
||||
|
||||
GPUStorageBuf *get_patch_index_buf() override
|
||||
gpu::StorageBuf *get_patch_index_buf() override
|
||||
{
|
||||
return getPatchTable()->GetPatchIndexBuffer();
|
||||
}
|
||||
|
||||
GPUStorageBuf *get_patch_param_buf() override
|
||||
gpu::StorageBuf *get_patch_param_buf() override
|
||||
{
|
||||
return getPatchTable()->GetPatchParamBuffer();
|
||||
}
|
||||
@@ -53,15 +53,15 @@ class GpuEvalOutput : public VolatileEvalOutput<GPUVertexBuffer,
|
||||
return getSrcVertexDataBuffer()->get_vertex_buffer();
|
||||
}
|
||||
|
||||
GPUStorageBuf *create_face_varying_patch_array_buf(const int face_varying_channel) override;
|
||||
gpu::StorageBuf *create_face_varying_patch_array_buf(const int face_varying_channel) override;
|
||||
|
||||
GPUStorageBuf *get_face_varying_patch_index_buf(const int face_varying_channel) override
|
||||
gpu::StorageBuf *get_face_varying_patch_index_buf(const int face_varying_channel) override
|
||||
{
|
||||
GPUPatchTable *patch_table = getFVarPatchTable(face_varying_channel);
|
||||
return patch_table->GetFVarPatchIndexBuffer(face_varying_channel);
|
||||
}
|
||||
|
||||
GPUStorageBuf *get_face_varying_patch_param_buf(const int face_varying_channel) override
|
||||
gpu::StorageBuf *get_face_varying_patch_param_buf(const int face_varying_channel) override
|
||||
{
|
||||
GPUPatchTable *patch_table = getFVarPatchTable(face_varying_channel);
|
||||
return patch_table->GetFVarPatchParamBuffer(face_varying_channel);
|
||||
|
||||
@@ -352,17 +352,17 @@ void EvalOutputAPI::getPatchMap(blender::gpu::VertBuf *patch_map_handles,
|
||||
memcpy(buffer_nodes.data(), quadtree.data(), sizeof(PatchMap::QuadNode) * quadtree.size());
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::create_patch_arrays_buf()
|
||||
gpu::StorageBuf *EvalOutputAPI::create_patch_arrays_buf()
|
||||
{
|
||||
return implementation_->create_patch_arrays_buf();
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::get_patch_index_buf()
|
||||
gpu::StorageBuf *EvalOutputAPI::get_patch_index_buf()
|
||||
{
|
||||
return implementation_->get_patch_index_buf();
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::get_patch_param_buf()
|
||||
gpu::StorageBuf *EvalOutputAPI::get_patch_param_buf()
|
||||
{
|
||||
return implementation_->get_patch_param_buf();
|
||||
}
|
||||
@@ -377,17 +377,17 @@ gpu::VertBuf *EvalOutputAPI::get_source_data_buf()
|
||||
return implementation_->get_source_data_buf();
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::create_face_varying_patch_array_buf(const int face_varying_channel)
|
||||
gpu::StorageBuf *EvalOutputAPI::create_face_varying_patch_array_buf(const int face_varying_channel)
|
||||
{
|
||||
return implementation_->create_face_varying_patch_array_buf(face_varying_channel);
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::get_face_varying_patch_index_buf(const int face_varying_channel)
|
||||
gpu::StorageBuf *EvalOutputAPI::get_face_varying_patch_index_buf(const int face_varying_channel)
|
||||
{
|
||||
return implementation_->get_face_varying_patch_index_buf(face_varying_channel);
|
||||
}
|
||||
|
||||
GPUStorageBuf *EvalOutputAPI::get_face_varying_patch_param_buf(const int face_varying_channel)
|
||||
gpu::StorageBuf *EvalOutputAPI::get_face_varying_patch_param_buf(const int face_varying_channel)
|
||||
{
|
||||
return implementation_->get_face_varying_patch_param_buf(face_varying_channel);
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ using OpenSubdiv::Osd::PatchArrayVector;
|
||||
|
||||
namespace blender::opensubdiv {
|
||||
|
||||
template<class T> GPUStorageBuf *create_buffer(std::vector<T> const &src, const char *name)
|
||||
template<class T> gpu::StorageBuf *create_buffer(std::vector<T> const &src, const char *name)
|
||||
{
|
||||
if (src.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const size_t buffer_size = src.size() * sizeof(T);
|
||||
GPUStorageBuf *storage_buffer = GPU_storagebuf_create_ex(
|
||||
gpu::StorageBuf *storage_buffer = GPU_storagebuf_create_ex(
|
||||
buffer_size, &src.at(0), GPU_USAGE_STATIC, name);
|
||||
|
||||
return storage_buffer;
|
||||
@@ -88,7 +88,7 @@ GPUStencilTableSSBO::GPUStencilTableSSBO(LimitStencilTable const *limitStencilTa
|
||||
}
|
||||
}
|
||||
|
||||
static void storage_buffer_free(GPUStorageBuf **buffer)
|
||||
static void storage_buffer_free(gpu::StorageBuf **buffer)
|
||||
{
|
||||
if (*buffer) {
|
||||
GPU_storagebuf_free(*buffer);
|
||||
@@ -195,12 +195,12 @@ bool GPUComputeEvaluator::EvalStencils(gpu::VertBuf *srcBuffer,
|
||||
BufferDescriptor const &duDesc,
|
||||
gpu::VertBuf *dvBuffer,
|
||||
BufferDescriptor const &dvDesc,
|
||||
GPUStorageBuf *sizesBuffer,
|
||||
GPUStorageBuf *offsetsBuffer,
|
||||
GPUStorageBuf *indicesBuffer,
|
||||
GPUStorageBuf *weightsBuffer,
|
||||
GPUStorageBuf *duWeightsBuffer,
|
||||
GPUStorageBuf *dvWeightsBuffer,
|
||||
gpu::StorageBuf *sizesBuffer,
|
||||
gpu::StorageBuf *offsetsBuffer,
|
||||
gpu::StorageBuf *indicesBuffer,
|
||||
gpu::StorageBuf *weightsBuffer,
|
||||
gpu::StorageBuf *duWeightsBuffer,
|
||||
gpu::StorageBuf *dvWeightsBuffer,
|
||||
int start,
|
||||
int end) const
|
||||
{
|
||||
@@ -267,8 +267,8 @@ bool GPUComputeEvaluator::EvalPatches(gpu::VertBuf *srcBuffer,
|
||||
int numPatchCoords,
|
||||
gpu::VertBuf *patchCoordsBuffer,
|
||||
const PatchArrayVector &patchArrays,
|
||||
GPUStorageBuf *patchIndexBuffer,
|
||||
GPUStorageBuf *patchParamsBuffer)
|
||||
gpu::StorageBuf *patchIndexBuffer,
|
||||
gpu::StorageBuf *patchParamsBuffer)
|
||||
{
|
||||
if (_patchKernel.shader == nullptr) {
|
||||
return false;
|
||||
|
||||
@@ -45,39 +45,39 @@ class GPUStencilTableSSBO {
|
||||
~GPUStencilTableSSBO();
|
||||
|
||||
// interfaces needed for GLSLComputeKernel
|
||||
GPUStorageBuf *GetSizesBuffer() const
|
||||
gpu::StorageBuf *GetSizesBuffer() const
|
||||
{
|
||||
return sizes_buf;
|
||||
}
|
||||
GPUStorageBuf *GetOffsetsBuffer() const
|
||||
gpu::StorageBuf *GetOffsetsBuffer() const
|
||||
{
|
||||
return offsets_buf;
|
||||
}
|
||||
GPUStorageBuf *GetIndicesBuffer() const
|
||||
gpu::StorageBuf *GetIndicesBuffer() const
|
||||
{
|
||||
return indices_buf;
|
||||
}
|
||||
GPUStorageBuf *GetWeightsBuffer() const
|
||||
gpu::StorageBuf *GetWeightsBuffer() const
|
||||
{
|
||||
return weights_buf;
|
||||
}
|
||||
GPUStorageBuf *GetDuWeightsBuffer() const
|
||||
gpu::StorageBuf *GetDuWeightsBuffer() const
|
||||
{
|
||||
return du_weights_buf;
|
||||
}
|
||||
GPUStorageBuf *GetDvWeightsBuffer() const
|
||||
gpu::StorageBuf *GetDvWeightsBuffer() const
|
||||
{
|
||||
return dv_weights_buf;
|
||||
}
|
||||
GPUStorageBuf *GetDuuWeightsBuffer() const
|
||||
gpu::StorageBuf *GetDuuWeightsBuffer() const
|
||||
{
|
||||
return duu_weights_buf;
|
||||
}
|
||||
GPUStorageBuf *GetDuvWeightsBuffer() const
|
||||
gpu::StorageBuf *GetDuvWeightsBuffer() const
|
||||
{
|
||||
return duv_weights_buf;
|
||||
}
|
||||
GPUStorageBuf *GetDvvWeightsBuffer() const
|
||||
gpu::StorageBuf *GetDvvWeightsBuffer() const
|
||||
{
|
||||
return dvv_weights_buf;
|
||||
}
|
||||
@@ -87,15 +87,15 @@ class GPUStencilTableSSBO {
|
||||
}
|
||||
|
||||
private:
|
||||
GPUStorageBuf *sizes_buf = nullptr;
|
||||
GPUStorageBuf *offsets_buf = nullptr;
|
||||
GPUStorageBuf *indices_buf = nullptr;
|
||||
GPUStorageBuf *weights_buf = nullptr;
|
||||
GPUStorageBuf *du_weights_buf = nullptr;
|
||||
GPUStorageBuf *dv_weights_buf = nullptr;
|
||||
GPUStorageBuf *duu_weights_buf = nullptr;
|
||||
GPUStorageBuf *duv_weights_buf = nullptr;
|
||||
GPUStorageBuf *dvv_weights_buf = nullptr;
|
||||
gpu::StorageBuf *sizes_buf = nullptr;
|
||||
gpu::StorageBuf *offsets_buf = nullptr;
|
||||
gpu::StorageBuf *indices_buf = nullptr;
|
||||
gpu::StorageBuf *weights_buf = nullptr;
|
||||
gpu::StorageBuf *du_weights_buf = nullptr;
|
||||
gpu::StorageBuf *dv_weights_buf = nullptr;
|
||||
gpu::StorageBuf *duu_weights_buf = nullptr;
|
||||
gpu::StorageBuf *duv_weights_buf = nullptr;
|
||||
gpu::StorageBuf *dvv_weights_buf = nullptr;
|
||||
int _numStencils;
|
||||
};
|
||||
|
||||
@@ -428,12 +428,12 @@ class GPUComputeEvaluator {
|
||||
OpenSubdiv::Osd::BufferDescriptor const &duDesc,
|
||||
gpu::VertBuf *dvBuffer,
|
||||
OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
|
||||
GPUStorageBuf *sizesBuffer,
|
||||
GPUStorageBuf *offsetsBuffer,
|
||||
GPUStorageBuf *indicesBuffer,
|
||||
GPUStorageBuf *weightsBuffer,
|
||||
GPUStorageBuf *duWeightsBuffer,
|
||||
GPUStorageBuf *dvWeightsBuffer,
|
||||
gpu::StorageBuf *sizesBuffer,
|
||||
gpu::StorageBuf *offsetsBuffer,
|
||||
gpu::StorageBuf *indicesBuffer,
|
||||
gpu::StorageBuf *weightsBuffer,
|
||||
gpu::StorageBuf *duWeightsBuffer,
|
||||
gpu::StorageBuf *dvWeightsBuffer,
|
||||
int start,
|
||||
int end) const;
|
||||
|
||||
@@ -735,8 +735,8 @@ class GPUComputeEvaluator {
|
||||
int numPatchCoords,
|
||||
gpu::VertBuf *patchCoordsBuffer,
|
||||
const OpenSubdiv::Osd::PatchArrayVector &patchArrays,
|
||||
GPUStorageBuf *patchIndexBuffer,
|
||||
GPUStorageBuf *patchParamsBuffer);
|
||||
gpu::StorageBuf *patchIndexBuffer,
|
||||
gpu::StorageBuf *patchParamsBuffer);
|
||||
|
||||
/// \brief Generic limit eval function. This function has a same
|
||||
/// signature as other device kernels have so that it can be called
|
||||
@@ -1381,7 +1381,7 @@ class GPUComputeEvaluator {
|
||||
} _patchKernel;
|
||||
|
||||
int _workGroupSize;
|
||||
GPUStorageBuf *_patchArraysSSBO = nullptr;
|
||||
gpu::StorageBuf *_patchArraysSSBO = nullptr;
|
||||
|
||||
int GetDispatchSize(int count) const;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ GPUPatchTable *GPUPatchTable::Create(PatchTable const *far_patch_table, void * /
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void discard_buffer(GPUStorageBuf **buffer)
|
||||
static void discard_buffer(gpu::StorageBuf **buffer)
|
||||
{
|
||||
if (*buffer != nullptr) {
|
||||
GPU_storagebuf_free(*buffer);
|
||||
@@ -29,10 +29,10 @@ static void discard_buffer(GPUStorageBuf **buffer)
|
||||
}
|
||||
}
|
||||
|
||||
static void discard_list(std::vector<GPUStorageBuf *> &buffers)
|
||||
static void discard_list(std::vector<gpu::StorageBuf *> &buffers)
|
||||
{
|
||||
while (!buffers.empty()) {
|
||||
GPUStorageBuf *buffer = buffers.back();
|
||||
gpu::StorageBuf *buffer = buffers.back();
|
||||
buffers.pop_back();
|
||||
GPU_storagebuf_free(buffer);
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ class GPUPatchTable : private NonCopyable<GPUPatchTable> {
|
||||
}
|
||||
|
||||
/// Returns the GL index buffer containing the patch control vertices
|
||||
GPUStorageBuf *GetPatchIndexBuffer() const
|
||||
gpu::StorageBuf *GetPatchIndexBuffer() const
|
||||
{
|
||||
return _patchIndexBuffer;
|
||||
}
|
||||
|
||||
/// Returns the GL index buffer containing the patch parameter
|
||||
GPUStorageBuf *GetPatchParamBuffer() const
|
||||
gpu::StorageBuf *GetPatchParamBuffer() const
|
||||
{
|
||||
return _patchParamBuffer;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class GPUPatchTable : private NonCopyable<GPUPatchTable> {
|
||||
}
|
||||
|
||||
/// Returns the GL index buffer containing the varying control vertices
|
||||
GPUStorageBuf *GetVaryingPatchIndexBuffer() const
|
||||
gpu::StorageBuf *GetVaryingPatchIndexBuffer() const
|
||||
{
|
||||
return _varyingIndexBuffer;
|
||||
}
|
||||
@@ -67,13 +67,13 @@ class GPUPatchTable : private NonCopyable<GPUPatchTable> {
|
||||
}
|
||||
|
||||
/// Returns the GL index buffer containing face-varying control vertices
|
||||
GPUStorageBuf *GetFVarPatchIndexBuffer(int fvarChannel = 0) const
|
||||
gpu::StorageBuf *GetFVarPatchIndexBuffer(int fvarChannel = 0) const
|
||||
{
|
||||
return _fvarIndexBuffers[fvarChannel];
|
||||
}
|
||||
|
||||
/// Returns the GL index buffer containing face-varying patch params
|
||||
GPUStorageBuf *GetFVarPatchParamBuffer(int fvarChannel = 0) const
|
||||
gpu::StorageBuf *GetFVarPatchParamBuffer(int fvarChannel = 0) const
|
||||
{
|
||||
return _fvarParamBuffers[fvarChannel];
|
||||
}
|
||||
@@ -86,15 +86,15 @@ class GPUPatchTable : private NonCopyable<GPUPatchTable> {
|
||||
|
||||
PatchArrayVector _patchArrays;
|
||||
|
||||
GPUStorageBuf *_patchIndexBuffer = nullptr;
|
||||
GPUStorageBuf *_patchParamBuffer = nullptr;
|
||||
gpu::StorageBuf *_patchIndexBuffer = nullptr;
|
||||
gpu::StorageBuf *_patchParamBuffer = nullptr;
|
||||
|
||||
PatchArrayVector _varyingPatchArrays;
|
||||
GPUStorageBuf *_varyingIndexBuffer = nullptr;
|
||||
gpu::StorageBuf *_varyingIndexBuffer = nullptr;
|
||||
|
||||
std::vector<PatchArrayVector> _fvarPatchArrays;
|
||||
std::vector<GPUStorageBuf *> _fvarIndexBuffers;
|
||||
std::vector<GPUStorageBuf *> _fvarParamBuffers;
|
||||
std::vector<gpu::StorageBuf *> _fvarIndexBuffers;
|
||||
std::vector<gpu::StorageBuf *> _fvarParamBuffers;
|
||||
};
|
||||
|
||||
} // namespace blender::opensubdiv
|
||||
|
||||
@@ -139,13 +139,13 @@ class EvalOutputAPI {
|
||||
int *patches_are_triangular);
|
||||
|
||||
// Copy the patch arrays buffer used by OpenSubDiv for the source data to the given buffer.
|
||||
GPUStorageBuf *create_patch_arrays_buf();
|
||||
gpu::StorageBuf *create_patch_arrays_buf();
|
||||
|
||||
// Wrap the patch index buffer used by OpenSubDiv for the source data with the given buffer.
|
||||
GPUStorageBuf *get_patch_index_buf();
|
||||
gpu::StorageBuf *get_patch_index_buf();
|
||||
|
||||
// Wrap the patch param buffer used by OpenSubDiv for the source data with the given buffer.
|
||||
GPUStorageBuf *get_patch_param_buf();
|
||||
gpu::StorageBuf *get_patch_param_buf();
|
||||
|
||||
// Wrap the buffer used by OpenSubDiv for the source data with the given buffer.
|
||||
gpu::VertBuf *get_source_buf();
|
||||
@@ -155,15 +155,15 @@ class EvalOutputAPI {
|
||||
|
||||
// Copy the patch arrays buffer used by OpenSubDiv for the face varying channel with the given
|
||||
// buffer.
|
||||
GPUStorageBuf *create_face_varying_patch_array_buf(const int face_varying_channel);
|
||||
gpu::StorageBuf *create_face_varying_patch_array_buf(const int face_varying_channel);
|
||||
|
||||
// Wrap the patch index buffer used by OpenSubDiv for the face varying channel with the given
|
||||
// buffer.
|
||||
GPUStorageBuf *get_face_varying_patch_index_buf(const int face_varying_channel);
|
||||
gpu::StorageBuf *get_face_varying_patch_index_buf(const int face_varying_channel);
|
||||
|
||||
// Wrap the patch param buffer used by OpenSubDiv for the face varying channel with the given
|
||||
// buffer.
|
||||
GPUStorageBuf *get_face_varying_patch_param_buf(const int face_varying_channel);
|
||||
gpu::StorageBuf *get_face_varying_patch_param_buf(const int face_varying_channel);
|
||||
|
||||
// Wrap thebuffer used by OpenSubDiv for the face varying channel with the given buffer.
|
||||
gpu::VertBuf *get_face_varying_source_buf(const int face_varying_channel);
|
||||
|
||||
Reference in New Issue
Block a user