c5dcfb63d9
Coarse meshes with high polycount would show as corrupted when GPU subdivision is used with AMD cards This was caused by the OpenSubdiv library not taking `GL_MAX_COMPUTE_WORK_GROUP_COUNT` into account when dispatching computes. AMD drivers tend to set the limit lower than NVidia ones (2^16 for the former, and 2^32 for the latter, at least on my machine). This moves the `GLComputeEvaluator` from the OpenSubdiv library into `intern/opensubdiv` and modifies it to compute a dispatch size in a similar way as for the draw code: we split the dispatch size into a 2 dimensional value based on `GL_MAX_COMPUTE_WORK_GROUP_COUNT` and manually compute an index in the shader. We could have patched the OpenSubdiv library and sent the fix upstream (which can still be done), however, moving it to our side allows us to better control the `GLComputeEvaluator` and in the future remove some redundant work that it does compared to Blender (see T94644) and probably prepare the ground for Vulkan support. As a matter of fact, this patch also removes the OpenGL initialization that OpenSubdiv would do here. This removal is not related to the bug fix, but necessary to not have to copy more files/code over. Differential Revision: https://developer.blender.org/D14131
70 lines
2.7 KiB
C++
70 lines
2.7 KiB
C++
// Copyright 2021 Blender Foundation. All rights reserved.
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
//
|
|
// Author: Sergey Sharybin
|
|
|
|
#ifndef OPENSUBDIV_EVAL_OUTPUT_GPU_H_
|
|
#define OPENSUBDIV_EVAL_OUTPUT_GPU_H_
|
|
|
|
#include "internal/evaluator/eval_output.h"
|
|
#include "internal/evaluator/gl_compute_evaluator.h"
|
|
|
|
#include <opensubdiv/osd/glPatchTable.h>
|
|
#include <opensubdiv/osd/glVertexBuffer.h>
|
|
|
|
using OpenSubdiv::Osd::GLVertexBuffer;
|
|
|
|
namespace blender {
|
|
namespace opensubdiv {
|
|
|
|
class GpuEvalOutput : public VolatileEvalOutput<GLVertexBuffer,
|
|
GLVertexBuffer,
|
|
GLStencilTableSSBO,
|
|
GLPatchTable,
|
|
GLComputeEvaluator> {
|
|
public:
|
|
GpuEvalOutput(const StencilTable *vertex_stencils,
|
|
const StencilTable *varying_stencils,
|
|
const vector<const StencilTable *> &all_face_varying_stencils,
|
|
const int face_varying_width,
|
|
const PatchTable *patch_table,
|
|
EvaluatorCache *evaluator_cache = NULL);
|
|
|
|
void fillPatchArraysBuffer(OpenSubdiv_Buffer *patch_arrays_buffer) override;
|
|
|
|
void wrapPatchIndexBuffer(OpenSubdiv_Buffer *patch_index_buffer) override;
|
|
|
|
void wrapPatchParamBuffer(OpenSubdiv_Buffer *patch_param_buffer) override;
|
|
|
|
void wrapSrcBuffer(OpenSubdiv_Buffer *src_buffer) override;
|
|
|
|
void fillFVarPatchArraysBuffer(const int face_varying_channel,
|
|
OpenSubdiv_Buffer *patch_arrays_buffer) override;
|
|
|
|
void wrapFVarPatchIndexBuffer(const int face_varying_channel,
|
|
OpenSubdiv_Buffer *patch_index_buffer) override;
|
|
|
|
void wrapFVarPatchParamBuffer(const int face_varying_channel,
|
|
OpenSubdiv_Buffer *patch_param_buffer) override;
|
|
|
|
void wrapFVarSrcBuffer(const int face_varying_channel, OpenSubdiv_Buffer *src_buffer) override;
|
|
};
|
|
|
|
} // namespace opensubdiv
|
|
} // namespace blender
|
|
|
|
#endif // OPENSUBDIV_EVAL_OUTPUT_GPU_H_
|