1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:37:34 +00:00

LibGL+LibGPU+LibSoftGPU: Add virtual base class for Images

This introduces a new device independent base class for Images in LibGPU
that also keeps track of the device from which it was created in order
to prevent assigning images across devices.
This commit is contained in:
Stephan Unverwerth 2022-03-27 16:26:50 +02:00 committed by Andreas Kling
parent 1f3642ed48
commit 4a99875582
8 changed files with 69 additions and 26 deletions

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCounted.h>
#include <LibGPU/ImageDataLayout.h>
#include <LibGfx/Vector3.h>
namespace GPU {
class Image : public RefCounted<Image> {
public:
Image(void const* ownership_token)
: m_ownership_token { ownership_token }
{
}
virtual ~Image() { }
virtual void write_texels(unsigned layer, unsigned level, Vector3<unsigned> const& offset, Vector3<unsigned> const& size, void const* data, ImageDataLayout const& layout) = 0;
virtual void read_texels(unsigned layer, unsigned level, Vector3<unsigned> const& offset, Vector3<unsigned> const& size, void* data, ImageDataLayout const& layout) const = 0;
virtual void copy_texels(Image const& source, unsigned source_layer, unsigned source_level, Vector3<unsigned> const& source_offset, Vector3<unsigned> const& size, unsigned destination_layer, unsigned destination_level, Vector3<unsigned> const& destination_offset) = 0;
void const* ownership_token() const { return m_ownership_token; }
bool has_same_ownership_token(Image const& other) const { return other.ownership_token() == ownership_token(); }
private:
void const* const m_ownership_token { nullptr };
};
}

View file

@ -6,8 +6,8 @@
#pragma once
#include <LibGPU/Image.h>
#include <LibGfx/Vector4.h>
#include <LibSoftGPU/Image.h>
namespace GPU {
@ -37,7 +37,7 @@ enum class TextureEnvMode {
};
struct SamplerConfig final {
RefPtr<SoftGPU::Image> bound_image;
RefPtr<Image> bound_image;
MipMapFilter mipmap_filter { MipMapFilter::Nearest };
TextureFilter texture_mag_filter { TextureFilter::Linear };
TextureFilter texture_min_filter { TextureFilter::Linear };