Commit 696926d4 by Alexis Hetu Committed by Alexis Hétu

sw::Surface references removed from sampling code

vk::Format was expanded to include more format related checks and the sampler object now uses them. Whether or not the Sampler code ends up actually being used is unsure, but the code has been updated to use vk::Image instead of sw::Surface. This should be the last sw::Surface reference in Vulkan code. Bug b/126883332 Change-Id: Ib1b4c3ce87d0fdad5ac7238b7e86211a499871a5 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27490Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 9041bb7c
...@@ -71,8 +71,8 @@ namespace sw ...@@ -71,8 +71,8 @@ namespace sw
return memcmp(this, &state, sizeof(State)) == 0; return memcmp(this, &state, sizeof(State)) == 0;
} }
vk::Format sourceFormat = VK_FORMAT_UNDEFINED; vk::Format sourceFormat;
vk::Format destFormat = VK_FORMAT_UNDEFINED; vk::Format destFormat;
int destSamples = 0; int destSamples = 0;
}; };
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#include "Sampler.hpp" #include "Sampler.hpp"
#include "Context.hpp" #include "Context.hpp"
#include "Surface.hpp"
#include "Pipeline/PixelRoutine.hpp" #include "Pipeline/PixelRoutine.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImage.hpp"
#include <cstring> #include <cstring>
...@@ -48,8 +48,7 @@ namespace sw ...@@ -48,8 +48,7 @@ namespace sw
} }
} }
externalTextureFormat = VK_FORMAT_UNDEFINED; textureFormat = VK_FORMAT_UNDEFINED;
internalTextureFormat = VK_FORMAT_UNDEFINED;
textureType = TEXTURE_NULL; textureType = TEXTURE_NULL;
textureFilter = FILTER_LINEAR; textureFilter = FILTER_LINEAR;
...@@ -89,13 +88,13 @@ namespace sw ...@@ -89,13 +88,13 @@ namespace sw
if(textureType != TEXTURE_NULL) if(textureType != TEXTURE_NULL)
{ {
state.textureType = textureType; state.textureType = textureType;
state.textureFormat = internalTextureFormat; state.textureFormat = textureFormat;
state.textureFilter = getTextureFilter(); state.textureFilter = getTextureFilter();
state.addressingModeU = getAddressingModeU(); state.addressingModeU = getAddressingModeU();
state.addressingModeV = getAddressingModeV(); state.addressingModeV = getAddressingModeV();
state.addressingModeW = getAddressingModeW(); state.addressingModeW = getAddressingModeW();
state.mipmapFilter = mipmapFilter(); state.mipmapFilter = mipmapFilter();
state.sRGB = (sRGB && Surface::isSRGBreadable(externalTextureFormat)) || Surface::isSRGBformat(internalTextureFormat); state.sRGB = (sRGB && textureFormat.isSRGBreadable()) || textureFormat.isSRGBformat();
state.swizzleR = swizzleR; state.swizzleR = swizzleR;
state.swizzleG = swizzleG; state.swizzleG = swizzleG;
state.swizzleB = swizzleB; state.swizzleB = swizzleB;
...@@ -111,25 +110,33 @@ namespace sw ...@@ -111,25 +110,33 @@ namespace sw
return state; return state;
} }
void Sampler::setTextureLevel(int face, int level, Surface *surface, TextureType type) void Sampler::setTextureLevel(int face, int level, vk::Image *image, TextureType type)
{ {
if(surface) if(image)
{ {
Mipmap &mipmap = texture.mipmap[level]; Mipmap &mipmap = texture.mipmap[level];
border = surface->getBorder(); border = image->isCube() ? 1 : 0;
mipmap.buffer[face] = surface->lockInternal(-border, -border, 0, LOCK_UNLOCKED, PRIVATE); VkImageSubresourceLayers subresourceLayers =
{
VK_IMAGE_ASPECT_COLOR_BIT,
static_cast<uint32_t>(level),
static_cast<uint32_t>(face),
1
};
mipmap.buffer[face] = image->getTexelPointer({ -border, -border, 0 }, subresourceLayers);
if(face == 0) if(face == 0)
{ {
externalTextureFormat = surface->getExternalFormat(); VkImageAspectFlagBits aspect = VK_IMAGE_ASPECT_COLOR_BIT; // FIXME: get proper aspect
internalTextureFormat = surface->getInternalFormat(); textureFormat = image->getFormat(aspect);
int width = surface->getWidth(); VkExtent3D mipLevelExtent = image->getMipLevelExtent(level);
int height = surface->getHeight(); int width = mipLevelExtent.width;
int depth = surface->getDepth(); int height = mipLevelExtent.height;
int pitchP = surface->getInternalPitchP(); int depth = mipLevelExtent.depth;
int sliceP = surface->getInternalSliceP(); int pitchP = image->rowPitchBytes(aspect, level);
int sliceP = image->slicePitchBytes(aspect, level);
if(level == 0) if(level == 0)
{ {
...@@ -154,7 +161,7 @@ namespace sw ...@@ -154,7 +161,7 @@ namespace sw
texture.depthLOD[3] = depth * exp2LOD; texture.depthLOD[3] = depth * exp2LOD;
} }
if(Surface::isFloatFormat(internalTextureFormat)) if(textureFormat.isFloatFormat())
{ {
mipmap.fWidth[0] = (float)width / 65536.0f; mipmap.fWidth[0] = (float)width / 65536.0f;
mipmap.fWidth[1] = (float)width / 65536.0f; mipmap.fWidth[1] = (float)width / 65536.0f;
...@@ -221,7 +228,7 @@ namespace sw ...@@ -221,7 +228,7 @@ namespace sw
mipmap.sliceP[2] = sliceP; mipmap.sliceP[2] = sliceP;
mipmap.sliceP[3] = sliceP; mipmap.sliceP[3] = sliceP;
if(internalTextureFormat == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM) if(textureFormat.hasYuvFormat())
{ {
unsigned int YStride = pitchP; unsigned int YStride = pitchP;
unsigned int YSize = YStride * height; unsigned int YSize = YStride * height;
...@@ -382,10 +389,10 @@ namespace sw ...@@ -382,10 +389,10 @@ namespace sw
bool Sampler::hasUnsignedTexture() const bool Sampler::hasUnsignedTexture() const
{ {
return Surface::isUnsignedComponent(internalTextureFormat, 0) && return textureFormat.isUnsignedComponent(0) &&
Surface::isUnsignedComponent(internalTextureFormat, 1) && textureFormat.isUnsignedComponent(1) &&
Surface::isUnsignedComponent(internalTextureFormat, 2) && textureFormat.isUnsignedComponent(2) &&
Surface::isUnsignedComponent(internalTextureFormat, 3); textureFormat.isUnsignedComponent(3);
} }
bool Sampler::hasCubeTexture() const bool Sampler::hasCubeTexture() const
...@@ -438,7 +445,7 @@ namespace sw ...@@ -438,7 +445,7 @@ namespace sw
FilterType filter = textureFilter; FilterType filter = textureFilter;
if(gather && Surface::componentCount(internalTextureFormat) == 1) if(gather && textureFormat.componentCount() == 1)
{ {
filter = FILTER_GATHER; filter = FILTER_GATHER;
} }
......
...@@ -15,9 +15,15 @@ ...@@ -15,9 +15,15 @@
#ifndef sw_Sampler_hpp #ifndef sw_Sampler_hpp
#define sw_Sampler_hpp #define sw_Sampler_hpp
#include "Device/Color.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "Device/Surface.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include "Vulkan/VkFormat.h"
namespace vk
{
class Image;
}
namespace sw namespace sw
{ {
...@@ -147,7 +153,7 @@ namespace sw ...@@ -147,7 +153,7 @@ namespace sw
State(); State();
TextureType textureType; TextureType textureType;
VkFormat textureFormat; vk::Format textureFormat;
FilterType textureFilter; FilterType textureFilter;
AddressingMode addressingModeU; AddressingMode addressingModeU;
AddressingMode addressingModeV; AddressingMode addressingModeV;
...@@ -172,7 +178,7 @@ namespace sw ...@@ -172,7 +178,7 @@ namespace sw
State samplerState() const; State samplerState() const;
void setTextureLevel(int face, int level, Surface *surface, TextureType type); void setTextureLevel(int face, int level, vk::Image *image, TextureType type);
void setTextureFilter(FilterType textureFilter); void setTextureFilter(FilterType textureFilter);
void setMipmapFilter(MipmapType mipmapFilter); void setMipmapFilter(MipmapType mipmapFilter);
...@@ -214,8 +220,7 @@ namespace sw ...@@ -214,8 +220,7 @@ namespace sw
AddressingMode getAddressingModeW() const; AddressingMode getAddressingModeW() const;
CompareFunc getCompareFunc() const; CompareFunc getCompareFunc() const;
VkFormat externalTextureFormat; vk::Format textureFormat;
VkFormat internalTextureFormat;
TextureType textureType; TextureType textureType;
FilterType textureFilter; FilterType textureFilter;
......
...@@ -2057,7 +2057,7 @@ namespace sw ...@@ -2057,7 +2057,7 @@ namespace sw
Vector4s cs = sampleTexel(index, buffer); Vector4s cs = sampleTexel(index, buffer);
bool isInteger = Surface::isNonNormalizedInteger(state.textureFormat); bool isInteger = state.textureFormat.isNonNormalizedInteger();
int componentCount = textureComponentCount(); int componentCount = textureComponentCount();
for(int n = 0; n < componentCount; n++) for(int n = 0; n < componentCount; n++)
{ {
...@@ -2426,22 +2426,22 @@ namespace sw ...@@ -2426,22 +2426,22 @@ namespace sw
bool SamplerCore::hasFloatTexture() const bool SamplerCore::hasFloatTexture() const
{ {
return Surface::isFloatFormat(state.textureFormat); return state.textureFormat.isFloatFormat();
} }
bool SamplerCore::hasUnnormalizedIntegerTexture() const bool SamplerCore::hasUnnormalizedIntegerTexture() const
{ {
return Surface::isNonNormalizedInteger(state.textureFormat); return state.textureFormat.isNonNormalizedInteger();
} }
bool SamplerCore::hasUnsignedTextureComponent(int component) const bool SamplerCore::hasUnsignedTextureComponent(int component) const
{ {
return Surface::isUnsignedComponent(state.textureFormat, component); return state.textureFormat.isUnsignedComponent(component);
} }
int SamplerCore::textureComponentCount() const int SamplerCore::textureComponentCount() const
{ {
return Surface::componentCount(state.textureFormat); return state.textureFormat.componentCount();
} }
bool SamplerCore::hasThirdCoordinate() const bool SamplerCore::hasThirdCoordinate() const
...@@ -2451,275 +2451,31 @@ namespace sw ...@@ -2451,275 +2451,31 @@ namespace sw
bool SamplerCore::has16bitTextureFormat() const bool SamplerCore::has16bitTextureFormat() const
{ {
switch(state.textureFormat) return state.textureFormat.has16bitTextureFormat();
{
case VK_FORMAT_R5G6B5_UNORM_PACK16:
return true;
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT:
case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32_UINT:
case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_R32G32B32A32_UINT:
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16_SINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_SINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_SINT:
case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return false;
default:
ASSERT(false);
}
return false;
} }
bool SamplerCore::has8bitTextureComponents() const bool SamplerCore::has8bitTextureComponents() const
{ {
switch(state.textureFormat) return state.textureFormat.has8bitTextureComponents();
{
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT:
return true;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT:
case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32_UINT:
case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_R32G32B32A32_UINT:
case VK_FORMAT_R16_SINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_SINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_SINT:
case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return false;
default:
ASSERT(false);
}
return false;
} }
bool SamplerCore::has16bitTextureComponents() const bool SamplerCore::has16bitTextureComponents() const
{ {
switch(state.textureFormat) return state.textureFormat.has16bitTextureComponents();
{
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT:
case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32_UINT:
case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_R32G32B32A32_UINT:
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return false;
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16_SINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_SINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_SINT:
case VK_FORMAT_R16G16B16A16_UINT:
return true;
default:
ASSERT(false);
}
return false;
} }
bool SamplerCore::has32bitIntegerTextureComponents() const bool SamplerCore::has32bitIntegerTextureComponents() const
{ {
switch(state.textureFormat) return state.textureFormat.has32bitIntegerTextureComponents();
{
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16_SINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_SINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_SINT:
case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return false;
case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT:
case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32_UINT:
case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_R32G32B32A32_UINT:
return true;
default:
ASSERT(false);
}
return false;
} }
bool SamplerCore::hasYuvFormat() const bool SamplerCore::hasYuvFormat() const
{ {
switch(state.textureFormat) return state.textureFormat.hasYuvFormat();
{
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return true;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT:
case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32_UINT:
case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_R32G32B32A32_UINT:
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16_SINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_SINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_SINT:
case VK_FORMAT_R16G16B16A16_UINT:
return false;
default:
ASSERT(false);
}
return false;
} }
bool SamplerCore::isRGBComponent(int component) const bool SamplerCore::isRGBComponent(int component) const
{ {
switch(state.textureFormat) return state.textureFormat.isRGBComponent(component);
{
case VK_FORMAT_R5G6B5_UNORM_PACK16: return component < 3;
case VK_FORMAT_R8_SNORM: return component < 1;
case VK_FORMAT_R8G8_SNORM: return component < 2;
case VK_FORMAT_R8G8B8A8_SNORM: return component < 3;
case VK_FORMAT_R8_SINT: return component < 1;
case VK_FORMAT_R8_UINT: return component < 1;
case VK_FORMAT_R8G8_SINT: return component < 2;
case VK_FORMAT_R8G8_UINT: return component < 2;
case VK_FORMAT_R8G8B8A8_SINT: return component < 3;
case VK_FORMAT_R8G8B8A8_UINT: return component < 3;
case VK_FORMAT_R32_SINT: return component < 1;
case VK_FORMAT_R32_UINT: return component < 1;
case VK_FORMAT_R32G32_SINT: return component < 2;
case VK_FORMAT_R32G32_UINT: return component < 2;
case VK_FORMAT_R32G32B32A32_SINT: return component < 3;
case VK_FORMAT_R32G32B32A32_UINT: return component < 3;
case VK_FORMAT_R8G8_UNORM: return component < 2;
case VK_FORMAT_B8G8R8A8_UNORM: return component < 3;
case VK_FORMAT_R8G8B8A8_UNORM: return component < 3;
case VK_FORMAT_R8G8B8A8_SRGB: return component < 3;
case VK_FORMAT_R32_SFLOAT: return component < 1;
case VK_FORMAT_R32G32_SFLOAT: return component < 2;
case VK_FORMAT_R32G32B32A32_SFLOAT: return component < 3;
case VK_FORMAT_R8_UNORM: return component < 1;
case VK_FORMAT_R16G16_UNORM: return component < 2;
case VK_FORMAT_R16G16B16A16_UNORM: return component < 3;
case VK_FORMAT_R16_SINT: return component < 1;
case VK_FORMAT_R16_UINT: return component < 1;
case VK_FORMAT_R16G16_SINT: return component < 2;
case VK_FORMAT_R16G16_UINT: return component < 2;
case VK_FORMAT_R16G16B16A16_SINT: return component < 3;
case VK_FORMAT_R16G16B16A16_UINT: return component < 3;
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: return component < 3;
default:
ASSERT(false);
}
return false;
} }
} }
...@@ -28,6 +28,7 @@ namespace vk ...@@ -28,6 +28,7 @@ namespace vk
class Format class Format
{ {
public: public:
Format() {}
Format(VkFormat format) : format(format) {} Format(VkFormat format) : format(format) {}
inline operator VkFormat() const { return format; } inline operator VkFormat() const { return format; }
...@@ -40,8 +41,11 @@ public: ...@@ -40,8 +41,11 @@ public:
bool hasQuadLayout() const; bool hasQuadLayout() const;
bool isSRGBformat() const; bool isSRGBformat() const;
bool isSRGBreadable() const;
bool isSRGBwritable() const; bool isSRGBwritable() const;
bool isFloatFormat() const; bool isFloatFormat() const;
int componentCount() const;
bool isUnsignedComponent(int component) const; bool isUnsignedComponent(int component) const;
int bytes() const; int bytes() const;
...@@ -49,8 +53,17 @@ public: ...@@ -49,8 +53,17 @@ public:
int sliceB(int width, int height, int border, bool target) const; int sliceB(int width, int height, int border, bool target) const;
bool getScale(sw::float4 &scale) const; bool getScale(sw::float4 &scale) const;
// Texture sampling utilities
bool has16bitTextureFormat() const;
bool has8bitTextureComponents() const;
bool has16bitTextureComponents() const;
bool has32bitIntegerTextureComponents() const;
bool hasYuvFormat() const;
bool isRGBComponent(int component) const;
private: private:
VkFormat format; VkFormat format = VK_FORMAT_UNDEFINED;
}; };
} // namespace vk } // namespace vk
......
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
VkDeviceSize memoryOffset = 0; VkDeviceSize memoryOffset = 0;
VkImageCreateFlags flags = 0; VkImageCreateFlags flags = 0;
VkImageType imageType = VK_IMAGE_TYPE_2D; VkImageType imageType = VK_IMAGE_TYPE_2D;
Format format = VK_FORMAT_UNDEFINED; Format format;
VkExtent3D extent = {0, 0, 0}; VkExtent3D extent = {0, 0, 0};
uint32_t mipLevels = 0; uint32_t mipLevels = 0;
uint32_t arrayLayers = 0; uint32_t arrayLayers = 0;
......
...@@ -49,7 +49,7 @@ private: ...@@ -49,7 +49,7 @@ private:
Image* image = nullptr; Image* image = nullptr;
VkImageViewType viewType = VK_IMAGE_VIEW_TYPE_2D; VkImageViewType viewType = VK_IMAGE_VIEW_TYPE_2D;
Format format = VK_FORMAT_UNDEFINED; Format format;
VkComponentMapping components = {}; VkComponentMapping components = {};
VkImageSubresourceRange subresourceRange = {}; VkImageSubresourceRange subresourceRange = {};
}; };
......
...@@ -293,7 +293,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -293,7 +293,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
sw::Stream& input = context.input[desc.location]; sw::Stream& input = context.input[desc.location];
input.count = getNumberOfChannels(desc.format); input.count = getNumberOfChannels(desc.format);
input.type = getStreamType(desc.format); input.type = getStreamType(desc.format);
input.normalized = !sw::Surface::isNonNormalizedInteger(desc.format); input.normalized = !vk::Format(desc.format).isNonNormalizedInteger();
input.offset = desc.offset; input.offset = desc.offset;
input.binding = desc.binding; input.binding = desc.binding;
input.stride = bufferStrides[desc.binding]; input.stride = bufferStrides[desc.binding];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment