Vulkan: Store VkExtents3D in ImageHelper.

This makes the distinction between a gl::Extents (includes a depth
value for 2D array texture layer count) and a Vulkan extents (2D array
textures have a "1" for depth) clearer. Preparation refactor patch.

Bug: angleproject:3189
Change-Id: I9a13379c421e7f3c7856ac15b7a73013258ab9fe
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1709754
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill
2019-07-22 09:56:27 -04:00
committed by Commit Bot
parent da2b649ce9
commit deb43a31cc
5 changed files with 36 additions and 41 deletions

View File

@@ -20,14 +20,13 @@ GLuint CreateSimpleTexture2D()
glBindTexture(GL_TEXTURE_2D, texture);
// Load the texture: 2x2 Image, 3 bytes per pixel (R, G, B)
const size_t width = 2;
const size_t height = 2;
GLubyte pixels[width * height * 3] =
{
255, 0, 0, // Red
0, 255, 0, // Green
0, 0, 255, // Blue
255, 255, 0, // Yellow
const size_t width = 2;
const size_t height = 2;
GLubyte pixels[width * height * 3] = {
255, 0, 0, // Red
0, 255, 0, // Green
0, 0, 255, // Blue
255, 255, 0, // Yellow
};
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
@@ -48,21 +47,18 @@ GLuint CreateSimpleTextureCubemap()
glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
// Load the texture faces
GLubyte pixels[6][3] =
{
// Face 0 - Red
{ 255, 0, 0 },
// Face 1 - Green,
{ 0, 255, 0 },
// Face 3 - Blue
{ 0, 0, 255 },
// Face 4 - Yellow
{ 255, 255, 0 },
// Face 5 - Purple
{ 255, 0, 255 },
// Face 6 - White
{ 255, 255, 255 }
};
GLubyte pixels[6][3] = {// Face 0 - Red
{255, 0, 0},
// Face 1 - Green,
{0, 255, 0},
// Face 3 - Blue
{0, 0, 255},
// Face 4 - Yellow
{255, 255, 0},
// Face 5 - Purple
{255, 0, 255},
// Face 6 - White
{255, 255, 255}};
for (size_t i = 0; i < 6; i++)
{
@@ -80,7 +76,7 @@ GLuint CreateSimpleTextureCubemap()
GLuint CreateMipMappedTexture2D()
{
// Texture object handle
const size_t width = 256;
const size_t width = 256;
const size_t height = 256;
std::array<GLubyte, width * height * 3> pixels;
@@ -103,7 +99,7 @@ GLuint CreateMipMappedTexture2D()
rColor = 255 * (1 - ((y / checkerSize) % 2));
}
pixels[(y * height + x) * 3] = rColor;
pixels[(y * height + x) * 3] = rColor;
pixels[(y * height + x) * 3 + 1] = 0;
pixels[(y * height + x) * 3 + 2] = bColor;
}
@@ -117,7 +113,8 @@ GLuint CreateMipMappedTexture2D()
glBindTexture(GL_TEXTURE_2D, texture);
// Load mipmap level 0
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels.data());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,
pixels.data());
// Generate mipmaps
glGenerateMipmap(GL_TEXTURE_2D);

View File

@@ -885,7 +885,7 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
resolveRegion.srcOffset = {};
resolveRegion.dstSubresource = resolveRegion.srcSubresource;
resolveRegion.dstOffset = {};
gl_vk::GetExtent(image.image.getExtents(), &resolveRegion.extent);
resolveRegion.extent = image.image.getExtents();
ANGLE_TRY(image.image.recordCommands(contextVk, &swapCommands));
mColorImageMS.resolve(&image.image, resolveRegion, swapCommands);

View File

@@ -973,8 +973,8 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
const gl::Extents baseLevelExtents = mImage->getExtents();
uint32_t imageLayerCount = mImage->getLayerCount();
const VkExtent3D baseLevelExtents = mImage->getExtents();
uint32_t imageLayerCount = mImage->getLayerCount();
uint8_t *imageData = nullptr;
gl::Rectangle imageArea(0, 0, baseLevelExtents.width, baseLevelExtents.height);

View File

@@ -1523,7 +1523,7 @@ angle::Result ImageHelper::initExternal(Context *context,
ASSERT(textureType != gl::TextureType::Rectangle || layerCount == 1);
ASSERT(textureType != gl::TextureType::CubeMap || layerCount == gl::kCubeFaceCount);
mExtents = extents;
gl_vk::GetExtent(extents, &mExtents);
mFormat = &format;
mSamples = samples;
mLayerCount = layerCount;
@@ -1535,9 +1535,7 @@ angle::Result ImageHelper::initExternal(Context *context,
imageInfo.flags = GetImageCreateFlags(textureType);
imageInfo.imageType = gl_vk::GetImageType(textureType);
imageInfo.format = format.vkImageFormat;
imageInfo.extent.width = static_cast<uint32_t>(extents.width);
imageInfo.extent.height = static_cast<uint32_t>(extents.height);
imageInfo.extent.depth = static_cast<uint32_t>(extents.depth);
imageInfo.extent = mExtents;
imageInfo.mipLevels = mipLevels;
imageInfo.arrayLayers = mLayerCount;
imageInfo.samples = gl_vk::GetSamples(samples);
@@ -1688,7 +1686,7 @@ void ImageHelper::init2DWeakReference(VkImage handle,
{
ASSERT(!valid());
mExtents = extents;
gl_vk::GetExtent(extents, &mExtents);
mFormat = &format;
mSamples = samples;
mCurrentLayout = ImageLayout::Undefined;
@@ -1707,7 +1705,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
{
ASSERT(!valid());
mExtents = extents;
gl_vk::GetExtent(extents, &mExtents);
mFormat = &format;
mSamples = 1;
mLayerCount = layerCount;
@@ -1760,8 +1758,8 @@ VkImageLayout ImageHelper::getCurrentLayout() const
gl::Extents ImageHelper::getLevelExtents2D(uint32_t level) const
{
int width = std::max(mExtents.width >> level, 1);
int height = std::max(mExtents.height >> level, 1);
uint32_t width = std::max(mExtents.width >> level, 1u);
uint32_t height = std::max(mExtents.height >> level, 1u);
return gl::Extents(width, height, 1);
}
@@ -1922,8 +1920,8 @@ gl::Extents ImageHelper::getSize(const gl::ImageIndex &index) const
GLint mipLevel = index.getLevelIndex();
// Level 0 should be the size of the extents, after that every time you increase a level
// you shrink the extents by half.
return gl::Extents(std::max(1, mExtents.width >> mipLevel),
std::max(1, mExtents.height >> mipLevel), mExtents.depth);
return gl::Extents(std::max(1u, mExtents.width >> mipLevel),
std::max(1u, mExtents.height >> mipLevel), mExtents.depth);
}
// static

View File

@@ -719,7 +719,7 @@ class ImageHelper final : public CommandGraphResource
const Image &getImage() const { return mImage; }
const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; }
const gl::Extents &getExtents() const { return mExtents; }
const VkExtent3D &getExtents() const { return mExtents; }
uint32_t getLayerCount() const { return mLayerCount; }
uint32_t getLevelCount() const { return mLevelCount; }
const Format &getFormat() const { return *mFormat; }
@@ -927,7 +927,7 @@ class ImageHelper final : public CommandGraphResource
DeviceMemory mDeviceMemory;
// Image properties.
gl::Extents mExtents;
VkExtent3D mExtents;
const Format *mFormat;
GLint mSamples;