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
commit 4a99875582
Notes: sideshowbarker 2024-07-17 14:22:48 +09:00
8 changed files with 69 additions and 26 deletions

View file

@ -1219,7 +1219,7 @@ GPU::DepthType Device::get_depthbuffer_value(int x, int y)
return m_frame_buffer->depth_buffer()->scanline(y)[x];
}
NonnullRefPtr<Image> Device::create_image(GPU::ImageFormat format, unsigned width, unsigned height, unsigned depth, unsigned levels, unsigned layers)
NonnullRefPtr<GPU::Image> Device::create_image(GPU::ImageFormat format, unsigned width, unsigned height, unsigned depth, unsigned levels, unsigned layers)
{
VERIFY(format == GPU::ImageFormat::BGRA8888);
VERIFY(width > 0);
@ -1228,11 +1228,13 @@ NonnullRefPtr<Image> Device::create_image(GPU::ImageFormat format, unsigned widt
VERIFY(levels > 0);
VERIFY(layers > 0);
return adopt_ref(*new Image(width, height, depth, levels, layers));
return adopt_ref(*new Image(this, width, height, depth, levels, layers));
}
void Device::set_sampler_config(unsigned sampler, GPU::SamplerConfig const& config)
{
VERIFY(config.bound_image.is_null() || config.bound_image->ownership_token() == this);
m_samplers[sampler].set_config(config);
}