KRTexture2D::getDimensions has been extended to a Vector3i and promoted to KRTexture::getDimensions
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -286,7 +286,7 @@ VkImage KRTexture::getImage(KrDeviceHandle device)
|
|||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRTexture::allocate(KRDevice& device, hydra::Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation
|
bool KRTexture::allocate(KRDevice& device, hydra::Vector3i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
, const char* debug_label
|
, const char* debug_label
|
||||||
#endif
|
#endif
|
||||||
@@ -297,7 +297,7 @@ bool KRTexture::allocate(KRDevice& device, hydra::Vector2i dimensions, VkImageCr
|
|||||||
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
||||||
imageInfo.extent.width = static_cast<uint32_t>(dimensions.x);
|
imageInfo.extent.width = static_cast<uint32_t>(dimensions.x);
|
||||||
imageInfo.extent.height = static_cast<uint32_t>(dimensions.y);
|
imageInfo.extent.height = static_cast<uint32_t>(dimensions.y);
|
||||||
imageInfo.extent.depth = 1;
|
imageInfo.extent.depth = static_cast<uint32_t>(dimensions.z);
|
||||||
imageInfo.mipLevels = 1;
|
imageInfo.mipLevels = 1;
|
||||||
imageInfo.arrayLayers = 1;
|
imageInfo.arrayLayers = 1;
|
||||||
imageInfo.format = VK_FORMAT_R8G8B8A8_SRGB;
|
imageInfo.format = VK_FORMAT_R8G8B8A8_SRGB;
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
bool hasMipmaps();
|
bool hasMipmaps();
|
||||||
virtual int getFaceCount() const = 0;
|
virtual int getFaceCount() const = 0;
|
||||||
virtual VkFormat getFormat() const = 0;
|
virtual VkFormat getFormat() const = 0;
|
||||||
|
virtual hydra::Vector3i getDimensions() const = 0;
|
||||||
|
|
||||||
kraken_stream_level getStreamLevel();
|
kraken_stream_level getStreamLevel();
|
||||||
float getLastFrameLodCoverage() const;
|
float getLastFrameLodCoverage() const;
|
||||||
@@ -129,7 +130,7 @@ protected:
|
|||||||
float m_last_frame_max_lod_coverage;
|
float m_last_frame_max_lod_coverage;
|
||||||
texture_usage_t m_last_frame_usage;
|
texture_usage_t m_last_frame_usage;
|
||||||
|
|
||||||
bool allocate(KRDevice& device, hydra::Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation
|
bool allocate(KRDevice& device, hydra::Vector3i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
, const char* debug_label
|
, const char* debug_label
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ bool KRTexture2D::createGPUTexture(int lod_max_dim)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i dimensions2d = getDimensions();
|
Vector3i dimensions = getDimensions();
|
||||||
Vector3i dimensions = { dimensions2d.x, dimensions2d.y, 1 };
|
|
||||||
size_t bufferSize = getMemRequiredForSize(lod_max_dim);
|
size_t bufferSize = getMemRequiredForSize(lod_max_dim);
|
||||||
void* buffer = malloc(bufferSize);
|
void* buffer = malloc(bufferSize);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public:
|
|||||||
virtual bool save(mimir::Block& data) override;
|
virtual bool save(mimir::Block& data) override;
|
||||||
|
|
||||||
virtual bool getLodData(void* buffer, int lod_max_dim) = 0;
|
virtual bool getLodData(void* buffer, int lod_max_dim) = 0;
|
||||||
virtual hydra::Vector2i getDimensions() const = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mimir::Block* m_pData;
|
mimir::Block* m_pData;
|
||||||
|
|||||||
@@ -53,10 +53,13 @@ KRTextureAnimated::KRTextureAnimated(KRContext& context, std::string name) : KRT
|
|||||||
|
|
||||||
m_max_lod_max_dim = 2048;
|
m_max_lod_max_dim = 2048;
|
||||||
m_min_lod_max_dim = 64;
|
m_min_lod_max_dim = 64;
|
||||||
|
m_dimensions = Vector2i::Create(0, 0);
|
||||||
|
|
||||||
for (int i = 0; i < m_frame_count; i++) {
|
for (int i = 0; i < m_frame_count; i++) {
|
||||||
KRTexture2D* frame_texture = textureForFrame(i);
|
KRTexture2D* frame_texture = textureForFrame(i);
|
||||||
if (frame_texture) {
|
if (frame_texture) {
|
||||||
|
m_dimensions.x = std::max(m_dimensions.x, frame_texture->getDimensions().x);
|
||||||
|
m_dimensions.y = std::max(m_dimensions.y, frame_texture->getDimensions().y);
|
||||||
if (frame_texture->getMaxMipMap() < (int)m_max_lod_max_dim) m_max_lod_max_dim = frame_texture->getMaxMipMap();
|
if (frame_texture->getMaxMipMap() < (int)m_max_lod_max_dim) m_max_lod_max_dim = frame_texture->getMaxMipMap();
|
||||||
if (frame_texture->getMinMipMap() > (int)m_min_lod_max_dim) m_min_lod_max_dim = frame_texture->getMinMipMap();
|
if (frame_texture->getMinMipMap() > (int)m_min_lod_max_dim) m_min_lod_max_dim = frame_texture->getMinMipMap();
|
||||||
}
|
}
|
||||||
@@ -162,3 +165,8 @@ VkFormat KRTextureAnimated::getFormat() const
|
|||||||
{
|
{
|
||||||
return VK_FORMAT_UNDEFINED;
|
return VK_FORMAT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hydra::Vector3i KRTextureAnimated::getDimensions() const
|
||||||
|
{
|
||||||
|
return Vector3i::Create(m_dimensions.x, m_dimensions.y, 1);
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "KRTexture2D.h"
|
#include "KRTexture2D.h"
|
||||||
|
|
||||||
using namespace mimir;
|
using namespace mimir;
|
||||||
|
using namespace hydra;
|
||||||
|
|
||||||
class KRTextureAnimated : public KRTexture
|
class KRTextureAnimated : public KRTexture
|
||||||
{
|
{
|
||||||
@@ -54,6 +55,7 @@ public:
|
|||||||
virtual void resize(int max_dim) override;
|
virtual void resize(int max_dim) override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool createGPUTexture(int lod_max_dim) override;
|
bool createGPUTexture(int lod_max_dim) override;
|
||||||
@@ -64,4 +66,6 @@ private:
|
|||||||
std::string m_texture_base_name;
|
std::string m_texture_base_name;
|
||||||
std::string textureNameForFrame(int frame);
|
std::string textureNameForFrame(int frame);
|
||||||
KRTexture2D* textureForFrame(int frame);
|
KRTexture2D* textureForFrame(int frame);
|
||||||
|
|
||||||
|
Vector2i m_dimensions;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ using namespace hydra;
|
|||||||
|
|
||||||
KRTextureCube::KRTextureCube(KRContext& context, std::string name) : KRTexture(context, name)
|
KRTextureCube::KRTextureCube(KRContext& context, std::string name) : KRTexture(context, name)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_max_lod_max_dim = 2048;
|
m_max_lod_max_dim = 2048;
|
||||||
m_min_lod_max_dim = 64;
|
m_min_lod_max_dim = 64;
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ bool KRTextureCube::createGPUTexture(int lod_max_dim)
|
|||||||
success = false;
|
success = false;
|
||||||
} else {
|
} else {
|
||||||
KRTexture2D& tex = *m_textures[i];
|
KRTexture2D& tex = *m_textures[i];
|
||||||
Vector2i texDimensions = tex.getDimensions();
|
Vector2i texDimensions = tex.getDimensions().xy();
|
||||||
if (dimensions.x == 0) {
|
if (dimensions.x == 0) {
|
||||||
dimensions = texDimensions;
|
dimensions = texDimensions;
|
||||||
} else if (dimensions != texDimensions) {
|
} else if (dimensions != texDimensions) {
|
||||||
@@ -112,7 +111,7 @@ bool KRTextureCube::createGPUTexture(int lod_max_dim)
|
|||||||
texture.allocation = VK_NULL_HANDLE;
|
texture.allocation = VK_NULL_HANDLE;
|
||||||
texture.image = VK_NULL_HANDLE;
|
texture.image = VK_NULL_HANDLE;
|
||||||
|
|
||||||
if (!allocate(device, dimensions, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation
|
if (!allocate(device, Vector3i::Create(dimensions.x, dimensions.y, 1), VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
, getName().c_str()
|
, getName().c_str()
|
||||||
#endif
|
#endif
|
||||||
@@ -195,3 +194,8 @@ VkFormat KRTextureCube::getFormat() const
|
|||||||
// TODO - Implement
|
// TODO - Implement
|
||||||
return VK_FORMAT_UNDEFINED;
|
return VK_FORMAT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hydra::Vector3i KRTextureCube::getDimensions() const
|
||||||
|
{
|
||||||
|
return m_textures[0] ? m_textures[0]->getDimensions() : Vector3i::Zero();
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
virtual void requestResidency(float lodCoverage, texture_usage_t textureUsage) override;
|
virtual void requestResidency(float lodCoverage, texture_usage_t textureUsage) override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool createGPUTexture(int lod_max_dim) override;
|
bool createGPUTexture(int lod_max_dim) override;
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ KRTextureKTX::~KRTextureKTX()
|
|||||||
m_blocks.clear();
|
m_blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i KRTextureKTX::getDimensions() const
|
Vector3i KRTextureKTX::getDimensions() const
|
||||||
{
|
{
|
||||||
return hydra::Vector2i::Create(Vector2i::Create(m_header.pixelWidth, m_header.pixelHeight));
|
return hydra::Vector3i::Create(Vector3i::Create(m_header.pixelWidth, m_header.pixelHeight, m_header.pixelDepth));
|
||||||
}
|
}
|
||||||
|
|
||||||
int KRTextureKTX::getFaceCount() const
|
int KRTextureKTX::getFaceCount() const
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
bool getLodData(void* buffer, int lod_max_dim) override;
|
bool getLodData(void* buffer, int lod_max_dim) override;
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) override;
|
virtual long getMemRequiredForSize(int max_dim) override;
|
||||||
virtual hydra::Vector2i getDimensions() const override;
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ KRTextureKTX2::~KRTextureKTX2()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i KRTextureKTX2::getDimensions() const
|
Vector3i KRTextureKTX2::getDimensions() const
|
||||||
{
|
{
|
||||||
return Vector2i::Create(Vector2i::Create(m_header.pixelWidth, m_header.pixelHeight));
|
return Vector3i::Create(Vector3i::Create(m_header.pixelWidth, m_header.pixelHeight, m_header.pixelDepth));
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTextureKTX2::getMemRequiredForSize(int max_dim)
|
long KRTextureKTX2::getMemRequiredForSize(int max_dim)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
bool getLodData(void* buffer, int lod_max_dim) override;
|
bool getLodData(void* buffer, int lod_max_dim) override;
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) override;
|
virtual long getMemRequiredForSize(int max_dim) override;
|
||||||
virtual hydra::Vector2i getDimensions() const override;
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -163,9 +163,9 @@ long KRTexturePNG::getMemRequiredForSize(int max_dim)
|
|||||||
return m_imageSize;
|
return m_imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i KRTexturePNG::getDimensions() const
|
Vector3i KRTexturePNG::getDimensions() const
|
||||||
{
|
{
|
||||||
return m_dimensions;
|
return Vector3i::Create(m_dimensions.x, m_dimensions.y, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat KRTexturePNG::getFormat() const
|
VkFormat KRTexturePNG::getFormat() const
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) override;
|
virtual long getMemRequiredForSize(int max_dim) override;
|
||||||
virtual hydra::Vector2i getDimensions() const override;
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ KRTexturePVR::~KRTexturePVR()
|
|||||||
m_blocks.clear();
|
m_blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i KRTexturePVR::getDimensions() const
|
Vector3i KRTexturePVR::getDimensions() const
|
||||||
{
|
{
|
||||||
return Vector2i::Create(m_iWidth, m_iHeight);
|
return Vector3i::Create(m_iWidth, m_iHeight, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat KRTexturePVR::getFormat() const
|
VkFormat KRTexturePVR::getFormat() const
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
bool getLodData(void* buffer, int lod_max_dim) override;
|
bool getLodData(void* buffer, int lod_max_dim) override;
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) override;
|
virtual long getMemRequiredForSize(int max_dim) override;
|
||||||
virtual hydra::Vector2i getDimensions() const override;
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -343,9 +343,9 @@ long KRTextureTGA::getMemRequiredForSize(int max_dim)
|
|||||||
return m_imageSize;
|
return m_imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i KRTextureTGA::getDimensions() const
|
Vector3i KRTextureTGA::getDimensions() const
|
||||||
{
|
{
|
||||||
return m_dimensions;
|
return Vector3i::Create(m_dimensions.x, m_dimensions.y, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat KRTextureTGA::getFormat() const
|
VkFormat KRTextureTGA::getFormat() const
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) override;
|
virtual long getMemRequiredForSize(int max_dim) override;
|
||||||
virtual hydra::Vector2i getDimensions() const override;
|
virtual hydra::Vector3i getDimensions() const override;
|
||||||
virtual VkFormat getFormat() const override;
|
virtual VkFormat getFormat() const override;
|
||||||
virtual int getFaceCount() const override;
|
virtual int getFaceCount() const override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user