mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibGPU+LibSoftGPU: Move size and pixel format information to GPU::Image
Size and format information are the same for every implementation and do not need to be virtual. This removes the need to reimplement them for each driver.
This commit is contained in:
parent
dc8be499e6
commit
3b2ded1d44
6 changed files with 51 additions and 37 deletions
32
Userland/Libraries/LibGPU/Image.cpp
Normal file
32
Userland/Libraries/LibGPU/Image.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Math.h>
|
||||
#include <LibGPU/Image.h>
|
||||
|
||||
namespace GPU {
|
||||
|
||||
Image::Image(void const* ownership_token, GPU::PixelFormat const& pixel_format, u32 width, u32 height, u32 depth, u32 max_levels)
|
||||
: m_ownership_token { ownership_token }
|
||||
, m_pixel_format { pixel_format }
|
||||
{
|
||||
VERIFY(width > 0);
|
||||
VERIFY(height > 0);
|
||||
VERIFY(depth > 0);
|
||||
VERIFY(max_levels > 0);
|
||||
|
||||
u32 number_of_levels_in_full_chain = max(max(AK::log2(width), AK::log2(height)), AK::log2(depth)) + 1;
|
||||
m_mipmap_sizes.resize(min(max_levels, number_of_levels_in_full_chain));
|
||||
|
||||
for (u32 level = 0; level < m_mipmap_sizes.size(); ++level) {
|
||||
m_mipmap_sizes[level] = { width, height, depth };
|
||||
width = max(width / 2, 1);
|
||||
height = max(height / 2, 1);
|
||||
depth = max(depth / 2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue