10 #define TALVOS_IMAGE_H
14 #include "vulkan/vulkan_core.h"
40 Texel(
const VkClearColorValue &ClearColor);
44 template <
typename T> T
get(
unsigned C)
const
46 static_assert(
sizeof(T) == 4);
48 return ((T *)
Data)[C];
71 template <
typename T>
void set(
unsigned C, T Value)
73 static_assert(
sizeof(T) == 4);
75 ((T *)
Data)[C] = Value;
104 : Dev(Dev), Type(Type), Format(Format), Extent(Extent),
117 uint32_t
getDepth(uint32_t Level = 0)
const;
129 uint32_t
getHeight(uint32_t Level = 0)
const;
142 uint32_t Layer = 0, uint32_t MipLevel = 0)
const;
151 uint32_t
getWidth(uint32_t Level = 0)
const;
157 void read(Texel &T, uint64_t
Address, VkFormat ReadFormat)
const;
163 void write(
const Texel &T, uint64_t
Address, VkFormat WriteFormat)
const;
183 VkImageSubresourceRange Range);
192 uint32_t
getDepth(uint32_t Level = 0)
const;
198 uint32_t
getHeight(uint32_t Level = 0)
const;
211 uint32_t Layer = 0, uint32_t MipLevel = 0)
const;
217 uint32_t
getWidth(uint32_t Level = 0)
const;
233 uint32_t Layer = 0, uint32_t MipLevel = 0)
const;
237 uint32_t Layer = 0, uint32_t MipLevel = 0)
const;
256 Sampler(
const VkSamplerCreateInfo &CreateInfo) {
Info = CreateInfo; }
260 float R = 0,
float A = 0,
float Lod = 0)
const;
Image(Device &Dev, VkImageType Type, VkFormat Format, VkExtent3D Extent, uint32_t NumArrayLayers=1, uint32_t NumMipLevels=1)
Create an image.
uint64_t Address
The memory address of the image data.
VkFormat Format
The image format.
uint32_t getBaseMipLevel() const
Returns the base mip level of the image view.
void bindAddress(uint64_t Address)
Bind a memory address to the image (can only be called once).
void write(const Image::Texel &T, uint32_t X, uint32_t Y=0, uint32_t Z=0, uint32_t Layer=0, uint32_t MipLevel=0) const
Write a texel to the image view at the specified coordinate.
This class represents an image object.
uint64_t getMipLevelOffset(uint32_t Level) const
Returns the offset in bytes to the beginning of the specified mip level.
A combination of an image and a sampler used to access it.
bool hasAlphaChannel(VkFormat Format)
Returns true if Format includes an alpha channel.
uint32_t BaseArrayLayer
The base array layer.
void loadUInt(const T *Data)
Load unsigned integer texel components.
Object toObject(const Type *Ty) const
Create an object with type Ty from the texel data.
void sample(const ImageView *Image, Image::Texel &Texel, float S, float T=0, float R=0, float A=0, float Lod=0) const
Sample a texel from an image at the specified coordinates.
VkImageViewType Type
The type of the image view.
This class represents a view into a range of image subresources.
void set(unsigned C, T Value)
Set a component value in the texel.
uint32_t getElementSize(VkFormat Format)
Returns the size in bytes for each element of an image with type Format.
void write(const Texel &T, uint64_t Address) const
Write a texel to the image at the specified address.
void storeSNorm(T *Data) const
Store normalized texel components as signed integers.
void loadSInt(const T *Data)
Load signed integer texel components.
uint32_t getWidth(uint32_t Level=0) const
Returns the width of the image at the specified mip level.
uint32_t getNumArrayLayers() const
Returns the number of array layers in the image.
VkExtent3D Extent
The image extent.
void storeSInt(T *Data) const
Store signed integer texel components, truncating as necessary.
VkSamplerCreateInfo Info
The sampler parameters.
This class represents a single texel with four 32-bit component values.
VkFormat getFormat() const
Returns the format of the image.
const class ImageView * Image
uint32_t getNumArrayLayers() const
Returns the number of array layers in the image view.
void loadUNorm(const T *Data)
Load normalized texel components from unsigned integer data.
const Image & getImage() const
Returns the image that the image view corresponds to.
uint32_t getWidth(uint32_t Level=0) const
Get the width of the image view at the specified mip level.
uint32_t getBaseArrayLayer() const
Returns the base array layer of the image view.
VkFormat Format
The format of the image view.
uint32_t getDepth(uint32_t Level=0) const
Get the depth of the image view at the specified mip level.
uint32_t NumMipLevels
The number of mip levels.
ImageView(const Image &Img, VkImageViewType Type, VkFormat Format, VkImageSubresourceRange Range)
Create an image view.
uint32_t getHeight(uint32_t Level=0) const
Returns the height of the image at the specified mip level.
Texel()
Create a texel with uninitialized component values.
VkImageType Type
The image type.
void storeUNorm(T *Data) const
Store normalized texel components as unsigned integers.
A Device instance encapsulates properties and state for the virtual device.
uint32_t getDepth(uint32_t Level=0) const
Returns the depth of the image at the specified mip level.
This file declares the Object class.
void read(Texel &T, uint64_t Address) const
Read a texel from the image at the specified address.
This class represents a sampler object.
const uint8_t * getData() const
Returns a const pointer to the raw data backing the texel.
uint32_t getHeight(uint32_t Level=0) const
Get the height of the image view at the specified mip level.
uint32_t getElementSize() const
Returns the size in bytes of a single pixel in the image.
uint32_t NumArrayLayers
The number of array layers.
bool isCube() const
Returns true if this image view corresponds to a cube map.
VkImageType getType() const
Returns the type of the image.
VkExtent3D getExtent() const
Returns the size of a single layer of the image.
uint64_t getTotalSize() const
Returns the total size of the image (including all mip levels).
Device & Dev
The device this image view is created on.
uint32_t NumArrayLayers
The number of array layers.
This class represents a SPIR-V type.
uint32_t NumMipLevels
The number of mip levels.
VkFormat getFormat() const
Returns the format of the image.
bool is1D() const
Returns true if this image view corresponds to a 1D image.
bool is2D() const
Returns true if this image view corresponds to a 2D image.
void storeUInt(T *Data) const
Store unsigned integer texel components, truncating as necessary.
Sampler(const VkSamplerCreateInfo &CreateInfo)
Create a sampler.
uint64_t getTexelAddress(uint32_t X, uint32_t Y=0, uint32_t Z=0, uint32_t Layer=0, uint32_t MipLevel=0) const
Returns the address in memory of the texel at the specified coordinate.
VkImageViewType getType() const
Returns the type of the image view.
This class represents an instruction result.
void loadSNorm(const T *Data)
Load normalized texel components from signed integer data.
uint8_t Data[16]
The data backing this texel.
const class Sampler * Sampler
const Image & Img
The image that the image corresponds to.
uint64_t getAddress() const
Returns the memory address of the beginning of the image.
uint32_t BaseMipLevel
The base mip level.
void loadSFloat(const T *Data)
Load signed floating point texel components.
bool is3D() const
Returns true if this image view corresponds to a 3D image.
uint32_t getNumMipLevels() const
Returns the number of mip levels in the image view.
void read(Image::Texel &T, uint32_t X, uint32_t Y=0, uint32_t Z=0, uint32_t Layer=0, uint32_t MipLevel=0) const
Read a texel from the image view at the specified coordinate.
uint32_t getNumMipLevels() const
Returns the number of mip levels in the image.
uint64_t getTexelAddress(uint32_t X, uint32_t Y=0, uint32_t Z=0, uint32_t Layer=0, uint32_t MipLevel=0) const
Returns the address in memory of the texel at the specified coordinate.