GPU: Delete copy operations on classes that own resources

These own GPU objects, memory or refcounts in their destructors (or assert
there that they were torn down), so a copy would double-free. Nothing copies
them today; this keeps it that way. The manager base classes cover every
backend's subclass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-29 10:33:32 -06:00
1 parent 39049a67fd
commit 93f57a4f38
23 files changed
+70

No files matched your search

+2
View File
@@ -30,6 +30,8 @@ static inline int operator &(const GLBufferStrategy &lhs, const GLBufferStrategy
class GLRBuffer {
public:
GLRBuffer(const GLRBuffer &) = delete;
GLRBuffer &operator=(const GLRBuffer &) = delete;
GLRBuffer(GLuint target, size_t size) : target_(target), size_((int)size) {}
~GLRBuffer() {
if (buffer_) {
+9
View File
@@ -30,6 +30,8 @@ constexpr int MAX_GL_TEXTURE_SLOTS = 8;
class GLRTexture {
public:
GLRTexture(const GLRTexture &) = delete;
GLRTexture &operator=(const GLRTexture &) = delete;
GLRTexture(const Draw::DeviceCaps &caps, int width, int height, int depth, int numMips);
~GLRTexture();
@@ -53,6 +55,8 @@ public:
class GLRFramebuffer {
public:
GLRFramebuffer(const GLRFramebuffer &) = delete;
GLRFramebuffer &operator=(const GLRFramebuffer &) = delete;
GLRFramebuffer(const Draw::DeviceCaps &caps, int _width, int _height, bool z_stencil, const char *tag)
: color_texture(caps, _width, _height, 1, 1), z_stencil_texture(caps, _width, _height, 1, 1),
width(_width), height(_height), z_stencil_(z_stencil) {
@@ -83,6 +87,8 @@ private:
class GLRShader {
public:
GLRShader(const GLRShader &) = delete;
GLRShader &operator=(const GLRShader &) = delete;
explicit GLRShader(std::string_view _desc) : desc(_desc) {}
~GLRShader() {
if (shader) {
@@ -116,6 +122,9 @@ public:
class GLRProgram {
public:
GLRProgram() = default;
GLRProgram(const GLRProgram &) = delete;
GLRProgram &operator=(const GLRProgram &) = delete;
~GLRProgram() {
if (deleteCallback_) {
deleteCallback_(deleteParam_);
+2
View File
@@ -12,6 +12,8 @@ struct VKRImage;
class VulkanBarrierBatch {
public:
VulkanBarrierBatch(const VulkanBarrierBatch &) = delete;
VulkanBarrierBatch &operator=(const VulkanBarrierBatch &) = delete;
VulkanBarrierBatch() : imageBarriers_(4) {}
~VulkanBarrierBatch();
+2
View File
@@ -18,6 +18,8 @@ enum class BindingType {
// Only appropriate for use in a per-frame pool.
class VulkanDescSetPool {
public:
VulkanDescSetPool(const VulkanDescSetPool &) = delete;
VulkanDescSetPool &operator=(const VulkanDescSetPool &) = delete;
VulkanDescSetPool(const char *tag, bool grow = true) : tag_(tag), grow_(grow) {}
~VulkanDescSetPool();
+2
View File
@@ -60,6 +60,8 @@ struct VKRImage {
class VKRFramebuffer {
public:
VKRFramebuffer(const VKRFramebuffer &) = delete;
VKRFramebuffer &operator=(const VKRFramebuffer &) = delete;
VKRFramebuffer(VulkanContext *vk, VulkanBarrierBatch *barriers, int _width, int _height, int _numLayers, int _multiSampleLevel, bool createDepthStencilBuffer, const char *tag);
~VKRFramebuffer();
+2
View File
@@ -22,6 +22,8 @@ struct TextureCopyBatch {
// ALWAYS use an allocator when calling CreateDirect.
class VulkanTexture {
public:
VulkanTexture(const VulkanTexture &) = delete;
VulkanTexture &operator=(const VulkanTexture &) = delete;
VulkanTexture(VulkanContext *vulkan, const char *tag);
~VulkanTexture() {
Destroy();
+5
View File
@@ -115,6 +115,8 @@ public:
// Wrapped pipeline. Does own desc!
struct VKRGraphicsPipeline {
VKRGraphicsPipeline(const VKRGraphicsPipeline &) = delete;
VKRGraphicsPipeline &operator=(const VKRGraphicsPipeline &) = delete;
VKRGraphicsPipeline(PipelineFlags flags, const char *tag) : flags_(flags), tag_(tag) {}
~VKRGraphicsPipeline();
@@ -195,6 +197,9 @@ static_assert(sizeof(PackedDescriptor::buffer) == 16, "PackedDescriptor should b
// Note that we only support a single descriptor set due to compatibility with some ancient devices.
// We should probably eventually give that up eventually.
struct VKRPipelineLayout {
VKRPipelineLayout() = default;
VKRPipelineLayout(const VKRPipelineLayout &) = delete;
VKRPipelineLayout &operator=(const VKRPipelineLayout &) = delete;
~VKRPipelineLayout();
enum { MAX_DESC_SET_BINDINGS = 5 };
+2
View File
@@ -51,6 +51,8 @@ class TextDrawer;
class DrawBuffer {
public:
DrawBuffer(const DrawBuffer &) = delete;
DrawBuffer &operator=(const DrawBuffer &) = delete;
DrawBuffer();
~DrawBuffer();
+6
View File
@@ -96,6 +96,9 @@ struct AtlasFontHeader {
};
struct AtlasFont {
AtlasFont() = default;
AtlasFont(const AtlasFont &) = delete;
AtlasFont &operator=(const AtlasFont &) = delete;
~AtlasFont();
float padding;
@@ -126,6 +129,9 @@ struct AtlasHeader {
};
struct Atlas {
Atlas() = default;
Atlas(const Atlas &) = delete;
Atlas &operator=(const Atlas &) = delete;
~Atlas();
bool LoadMeta(const uint8_t *data, size_t data_size);
bool IsMetadataLoaded() const {
+2
View File
@@ -73,6 +73,8 @@ struct alignas(16) Plane8 {
class DrawEngineCommon {
public:
DrawEngineCommon(const DrawEngineCommon &) = delete;
DrawEngineCommon &operator=(const DrawEngineCommon &) = delete;
DrawEngineCommon();
virtual ~DrawEngineCommon();
+2
View File
@@ -291,6 +291,8 @@ struct DisplayLayoutConfig;
class FramebufferManagerCommon {
public:
FramebufferManagerCommon(const FramebufferManagerCommon &) = delete;
FramebufferManagerCommon &operator=(const FramebufferManagerCommon &) = delete;
FramebufferManagerCommon(Draw::DrawContext *draw);
virtual ~FramebufferManagerCommon();
+2
View File
@@ -80,6 +80,8 @@ ENUM_CLASS_BITOPS(OutputFlags);
class PresentationCommon {
public:
PresentationCommon(const PresentationCommon &) = delete;
PresentationCommon &operator=(const PresentationCommon &) = delete;
PresentationCommon(Draw::DrawContext *draw);
~PresentationCommon();
+2
View File
@@ -140,6 +140,8 @@ struct ReplacedTextureLevel {
class ReplacedTexture {
public:
ReplacedTexture(const ReplacedTexture &) = delete;
ReplacedTexture &operator=(const ReplacedTexture &) = delete;
ReplacedTexture(VFSBackend *vfs, const ReplacementDesc &desc);
~ReplacedTexture();
+2
View File
@@ -123,6 +123,8 @@ enum : uint64_t {
class ShaderManagerCommon {
public:
ShaderManagerCommon(const ShaderManagerCommon &) = delete;
ShaderManagerCommon &operator=(const ShaderManagerCommon &) = delete;
ShaderManagerCommon(Draw::DrawContext *draw) : draw_(draw) {}
virtual ~ShaderManagerCommon() {}
+5
View File
@@ -160,6 +160,9 @@ ENUM_CLASS_BITOPS(TexStatus);
// TODO: Shrink this struct. There is some fluff.
struct TexCacheEntry {
TexCacheEntry() = default;
TexCacheEntry(const TexCacheEntry &) = delete;
TexCacheEntry &operator=(const TexCacheEntry &) = delete;
~TexCacheEntry() {
#ifdef _DEBUG
if (texturePtr || textureName || vkTex)
@@ -338,6 +341,8 @@ struct TextureApplyResult {
class TextureCacheCommon {
public:
TextureCacheCommon(const TextureCacheCommon &) = delete;
TextureCacheCommon &operator=(const TextureCacheCommon &) = delete;
TextureCacheCommon(Draw::DrawContext *draw, Draw2D *draw2D);
virtual ~TextureCacheCommon();
+2
View File
@@ -76,6 +76,8 @@ enum class ReplacerDecimateMode {
class TextureReplacer {
public:
TextureReplacer(const TextureReplacer &) = delete;
TextureReplacer &operator=(const TextureReplacer &) = delete;
// The draw context is checked for supported texture formats.
TextureReplacer(Draw::DrawContext *draw);
~TextureReplacer();
+4
View File
@@ -37,6 +37,8 @@ class IOFile;
class LinkedShader {
public:
LinkedShader(const LinkedShader &) = delete;
LinkedShader &operator=(const LinkedShader &) = delete;
LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, FShaderID FSID, Shader *fs, bool useHWTransform, bool preloading = false);
~LinkedShader();
@@ -139,6 +141,8 @@ struct ShaderDescGLES {
class Shader {
public:
Shader(const Shader &) = delete;
Shader &operator=(const Shader &) = delete;
Shader(GLRenderManager *render, const char *code, const std::string &desc, const ShaderDescGLES &params);
~Shader();
GLRShader *shader;
+2
View File
@@ -56,6 +56,8 @@ inline bool IsTrianglePrim(GEPrimitiveType prim) {
struct TransformStats;
class GPUCommon {
public:
GPUCommon(const GPUCommon &) = delete;
GPUCommon &operator=(const GPUCommon &) = delete;
// The constructor might run on the loader thread.
GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
virtual ~GPUCommon() = default;
+4
View File
@@ -57,6 +57,8 @@ struct BinItem {
template <typename T, size_t N>
struct BinQueue {
BinQueue(const BinQueue &) = delete;
BinQueue &operator=(const BinQueue &) = delete;
BinQueue() {
Reset();
}
@@ -185,6 +187,8 @@ struct BinDirtyRange {
class StringWriter;
class BinManager {
public:
BinManager(const BinManager &) = delete;
BinManager &operator=(const BinManager &) = delete;
BinManager();
~BinManager();
+2
View File
@@ -111,6 +111,8 @@ class StringWriter;
class TransformUnit {
public:
TransformUnit(const TransformUnit &) = delete;
TransformUnit &operator=(const TransformUnit &) = delete;
TransformUnit();
~TransformUnit();
+3
View File
@@ -63,6 +63,9 @@ private:
// Simply wraps a Vulkan pipeline, providing some metadata.
struct VulkanPipeline {
VulkanPipeline() = default;
VulkanPipeline(const VulkanPipeline &) = delete;
VulkanPipeline &operator=(const VulkanPipeline &) = delete;
~VulkanPipeline() {
desc->Release();
}
+4
View File
@@ -40,6 +40,8 @@ class VulkanPushPool;
class VulkanFragmentShader {
public:
VulkanFragmentShader(const VulkanFragmentShader &) = delete;
VulkanFragmentShader &operator=(const VulkanFragmentShader &) = delete;
VulkanFragmentShader(VulkanContext *vulkan, FShaderID id, FragmentShaderFlags flags, const char *code, SPIRVCache *cache);
~VulkanFragmentShader();
@@ -63,6 +65,8 @@ protected:
class VulkanVertexShader {
public:
VulkanVertexShader(const VulkanVertexShader &) = delete;
VulkanVertexShader &operator=(const VulkanVertexShader &) = delete;
VulkanVertexShader(VulkanContext *vulkan, VShaderID id, VertexShaderFlags flags, const char *code, bool useHWTransform, SPIRVCache *cache);
~VulkanVertexShader();
+2
View File
@@ -37,6 +37,8 @@ class StringWriter;
class SamplerCache {
public:
SamplerCache(const SamplerCache &) = delete;
SamplerCache &operator=(const SamplerCache &) = delete;
SamplerCache(VulkanContext *vulkan) : vulkan_(vulkan), cache_(16) {}
~SamplerCache();
VkSampler GetOrCreateSampler(const SamplerCacheKey &key);