Commit 8a6dcf76 by Alexis Hetu Committed by Alexis Hétu

Support sample image instruction operand

- Added support for the sample operand in SamplerCore, which simply involves offsetting the buffer by the the sampleId * samplePitch. - Also added a check so that sampleId is within the expected range and doesn't cause reading memory out of bounds. Bug: b/135265531 Change-Id: Ie828d07db41d36befb34037156736a6576af0676 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38728Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 2613cb5e
...@@ -40,6 +40,8 @@ namespace sw ...@@ -40,6 +40,8 @@ namespace sw
short4 onePitchP; short4 onePitchP;
int4 pitchP; int4 pitchP;
int4 sliceP; int4 sliceP;
int4 samplePitchP;
int4 sampleMax;
}; };
struct Texture struct Texture
......
...@@ -60,20 +60,20 @@ namespace sw ...@@ -60,20 +60,20 @@ namespace sw
public: public:
SamplerCore(Pointer<Byte> &constants, const Sampler &state); SamplerCore(Pointer<Byte> &constants, const Sampler &state);
Vector4f sampleTexture(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Float &&lodOrBias, Float4 &dsx, Float4 &dsy, Vector4f &offset, SamplerFunction function); Vector4f sampleTexture(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Float &&lodOrBias, Float4 &dsx, Float4 &dsy, Vector4f &offset, Int4& sampleId, SamplerFunction function);
private: private:
Short4 offsetSample(Short4 &uvw, Pointer<Byte> &mipmap, int halfOffset, bool wrap, int count, Float &lod); Short4 offsetSample(Short4 &uvw, Pointer<Byte> &mipmap, int halfOffset, bool wrap, int count, Float &lod);
Vector4s sampleFilter(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, SamplerFunction function); Vector4s sampleFilter(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, SamplerFunction function);
Vector4s sampleAniso(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, bool secondLOD, SamplerFunction function); Vector4s sampleAniso(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, bool secondLOD, SamplerFunction function);
Vector4s sampleQuad(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4s sampleQuad(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Vector4s sampleQuad2D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4s sampleQuad2D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Vector4s sample3D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4s sample3D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Vector4f sampleFloatFilter(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, SamplerFunction function); Vector4f sampleFloatFilter(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, const Int4& sampleId, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, SamplerFunction function);
Vector4f sampleFloatAniso(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, bool secondLOD, SamplerFunction function); Vector4f sampleFloatAniso(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, const Int4& sampleId, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, bool secondLOD, SamplerFunction function);
Vector4f sampleFloat(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4f sampleFloat(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Vector4f sampleFloat2D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4f sampleFloat2D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Vector4f sampleFloat3D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function); Vector4f sampleFloat3D(Pointer<Byte> &texture, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, const Int4& sampleId, Float &lod, bool secondLOD, SamplerFunction function);
Float log2sqrt(Float lod); Float log2sqrt(Float lod);
Float log2(Float lod); Float log2(Float lod);
void computeLod(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, Float4 &dsx, Float4 &dsy, SamplerFunction function); void computeLod(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, Float4 &dsx, Float4 &dsy, SamplerFunction function);
...@@ -81,11 +81,11 @@ namespace sw ...@@ -81,11 +81,11 @@ namespace sw
void computeLod3D(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float &lod, Float4 &u, Float4 &v, Float4 &w, Float4 &dsx, Float4 &dsy, SamplerFunction function); void computeLod3D(Pointer<Byte> &texture, Pointer<Byte> &sampler, Float &lod, Float4 &u, Float4 &v, Float4 &w, Float4 &dsx, Float4 &dsy, SamplerFunction function);
Int4 cubeFace(Float4 &U, Float4 &V, Float4 &x, Float4 &y, Float4 &z, Float4 &M); Int4 cubeFace(Float4 &U, Float4 &V, Float4 &x, Float4 &y, Float4 &z, Float4 &M);
Short4 applyOffset(Short4 &uvw, Float4 &offset, const Int4 &whd, AddressingMode mode); Short4 applyOffset(Short4 &uvw, Float4 &offset, const Int4 &whd, AddressingMode mode);
void computeIndices(UInt index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, SamplerFunction function); void computeIndices(UInt index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, const Int4& sampleId, SamplerFunction function);
void computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww, Int4 valid, const Pointer<Byte> &mipmap, SamplerFunction function); void computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww, Int4 valid, const Pointer<Byte> &mipmap, const Int4& sampleId, SamplerFunction function);
Vector4s sampleTexel(Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Pointer<Byte> &mipmap, Pointer<Byte> buffer, SamplerFunction function); Vector4s sampleTexel(Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Pointer<Byte> &mipmap, const Int4& sampleId, Pointer<Byte> buffer, SamplerFunction function);
Vector4s sampleTexel(UInt index[4], Pointer<Byte> buffer); Vector4s sampleTexel(UInt index[4], Pointer<Byte> buffer);
Vector4f sampleTexel(Int4 &u, Int4 &v, Int4 &s, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer, SamplerFunction function); Vector4f sampleTexel(Int4 &u, Int4 &v, Int4 &s, Float4 &z, Pointer<Byte> &mipmap, const Int4& sampleId, Pointer<Byte> buffer, SamplerFunction function);
Vector4f replaceBorderTexel(const Vector4f &c, Int4 valid); Vector4f replaceBorderTexel(const Vector4f &c, Int4 valid);
void selectMipmap(const Pointer<Byte> &texture, Pointer<Byte> &mipmap, Pointer<Byte> &buffer, const Float &lod, bool secondLOD); void selectMipmap(const Pointer<Byte> &texture, Pointer<Byte> &mipmap, Pointer<Byte> &buffer, const Float &lod, bool secondLOD);
Short4 address(Float4 &uw, AddressingMode addressingMode, Pointer<Byte>& mipmap); Short4 address(Float4 &uw, AddressingMode addressingMode, Pointer<Byte>& mipmap);
......
...@@ -5169,7 +5169,7 @@ namespace sw ...@@ -5169,7 +5169,7 @@ namespace sw
if(sample) if(sample)
{ {
auto sampleValue = GenericValue(this, state, sampleId); auto sampleValue = GenericValue(this, state, sampleId);
in[i] = sampleValue.Float(0); in[i] = As<SIMD::Float>(sampleValue.Int(0));
} }
auto cacheIt = state->routine->samplerCache.find(resultId); auto cacheIt = state->routine->samplerCache.find(resultId);
......
...@@ -120,6 +120,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in ...@@ -120,6 +120,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in
Vector4f dsx = {0, 0, 0, 0}; Vector4f dsx = {0, 0, 0, 0};
Vector4f dsy = {0, 0, 0, 0}; Vector4f dsy = {0, 0, 0, 0};
Vector4f offset = {0, 0, 0, 0}; Vector4f offset = {0, 0, 0, 0};
SIMD::Int sampleId = 0;
SamplerFunction samplerFunction = instruction.getSamplerFunction(); SamplerFunction samplerFunction = instruction.getSamplerFunction();
uint32_t i = 0; uint32_t i = 0;
...@@ -169,7 +170,10 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in ...@@ -169,7 +170,10 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in
offset[j] = in[i]; offset[j] = in[i];
} }
// TODO(b/133868964): Handle 'Sample' operand. if(instruction.sample)
{
sampleId = As<SIMD::Int>(in[i]);
}
SamplerCore s(constants, samplerState); SamplerCore s(constants, samplerState);
...@@ -199,7 +203,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in ...@@ -199,7 +203,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in
dPdy.y = Float(0.0f); dPdy.y = Float(0.0f);
} }
Vector4f sample = s.sampleTexture(texture, sampler, uvw[0], uvw[1], uvw[2], q, lod[i], dPdx, dPdy, offset, samplerFunction); Vector4f sample = s.sampleTexture(texture, sampler, uvw[0], uvw[1], uvw[2], q, lod[i], dPdx, dPdy, offset, sampleId, samplerFunction);
Pointer<Float> rgba = out; Pointer<Float> rgba = out;
rgba[0 * SIMD::Width + i] = Pointer<Float>(&sample.x)[i]; rgba[0 * SIMD::Width + i] = Pointer<Float>(&sample.x)[i];
...@@ -210,7 +214,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in ...@@ -210,7 +214,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in
} }
else else
{ {
Vector4f sample = s.sampleTexture(texture, sampler, uvw[0], uvw[1], uvw[2], q, lodOrBias.x, (dsx.x), (dsy.x), offset, samplerFunction); Vector4f sample = s.sampleTexture(texture, sampler, uvw[0], uvw[1], uvw[2], q, lodOrBias.x, (dsx.x), (dsy.x), offset, sampleId, samplerFunction);
Pointer<SIMD::Float> rgba = out; Pointer<SIMD::Float> rgba = out;
rgba[0] = sample.x; rgba[0] = sample.x;
......
...@@ -384,13 +384,13 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS ...@@ -384,13 +384,13 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS
imageView->getFormat(VK_IMAGE_ASPECT_PLANE_0_BIT).bytes(); imageView->getFormat(VK_IMAGE_ASPECT_PLANE_0_BIT).bytes();
// Write plane 0 parameters to mipmap level 0. // Write plane 0 parameters to mipmap level 0.
WriteTextureLevelInfo(texture, 0, width, height, 1, pitchP0, 0); WriteTextureLevelInfo(texture, 0, width, height, 1, pitchP0, 0, 0, 0);
// Plane 2, if present, has equal parameters to plane 1, so we use mipmap level 1 for both. // Plane 2, if present, has equal parameters to plane 1, so we use mipmap level 1 for both.
int pitchP1 = imageView->rowPitchBytes(VK_IMAGE_ASPECT_PLANE_1_BIT, level, ImageView::SAMPLING) / int pitchP1 = imageView->rowPitchBytes(VK_IMAGE_ASPECT_PLANE_1_BIT, level, ImageView::SAMPLING) /
imageView->getFormat(VK_IMAGE_ASPECT_PLANE_1_BIT).bytes(); imageView->getFormat(VK_IMAGE_ASPECT_PLANE_1_BIT).bytes();
WriteTextureLevelInfo(texture, 1, width / 2, height / 2, 1, pitchP1, 0); WriteTextureLevelInfo(texture, 1, width / 2, height / 2, 1, pitchP1, 0, 0, 0);
} }
else else
{ {
...@@ -418,12 +418,15 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS ...@@ -418,12 +418,15 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS
int width = extent.width; int width = extent.width;
int height = extent.height; int height = extent.height;
int bytes = format.bytes();
int layers = imageView->getSubresourceRange().layerCount; // TODO(b/129523279): Untangle depth vs layers throughout the sampler int layers = imageView->getSubresourceRange().layerCount; // TODO(b/129523279): Untangle depth vs layers throughout the sampler
int depth = layers > 1 ? layers : extent.depth; int depth = layers > 1 ? layers : extent.depth;
int pitchP = imageView->rowPitchBytes(aspect, level, ImageView::SAMPLING) / format.bytes(); int pitchP = imageView->rowPitchBytes(aspect, level, ImageView::SAMPLING) / bytes;
int sliceP = (layers > 1 ? imageView->layerPitchBytes(aspect, ImageView::SAMPLING) : imageView->slicePitchBytes(aspect, level, ImageView::SAMPLING)) / format.bytes(); int sliceP = (layers > 1 ? imageView->layerPitchBytes(aspect, ImageView::SAMPLING) : imageView->slicePitchBytes(aspect, level, ImageView::SAMPLING)) / bytes;
int samplePitchP = imageView->getMipLevelSize(aspect, level, ImageView::SAMPLING) / bytes;
int sampleMax = imageView->getSampleCount() - 1;
WriteTextureLevelInfo(texture, mipmapLevel, width, height, depth, pitchP, sliceP); WriteTextureLevelInfo(texture, mipmapLevel, width, height, depth, pitchP, sliceP, samplePitchP, sampleMax);
} }
} }
} }
...@@ -451,9 +454,9 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS ...@@ -451,9 +454,9 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS
{ {
descriptor[i].stencilPtr = imageView->getOffsetPointer({0, 0, 0}, VK_IMAGE_ASPECT_STENCIL_BIT, 0, 0); descriptor[i].stencilPtr = imageView->getOffsetPointer({0, 0, 0}, VK_IMAGE_ASPECT_STENCIL_BIT, 0, 0);
descriptor[i].stencilRowPitchBytes = imageView->rowPitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT, 0); descriptor[i].stencilRowPitchBytes = imageView->rowPitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT, 0);
descriptor[i].stencilSamplePitchBytes = imageView->getSubresourceRange().layerCount > 1 descriptor[i].stencilSamplePitchBytes = (imageView->getSubresourceRange().layerCount > 1)
? imageView->layerPitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT) ? imageView->layerPitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT)
: imageView->slicePitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT, 0); : imageView->slicePitchBytes(VK_IMAGE_ASPECT_STENCIL_BIT, 0);
descriptor[i].stencilSlicePitchBytes = descriptor[i].stencilSamplePitchBytes * imageView->getSampleCount(); descriptor[i].stencilSlicePitchBytes = descriptor[i].stencilSamplePitchBytes * imageView->getSampleCount();
} }
} }
...@@ -492,7 +495,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS ...@@ -492,7 +495,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device* device, DescriptorSet *dstS
} }
} }
void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level, int width, int height, int depth, int pitchP, int sliceP) void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level, int width, int height, int depth, int pitchP, int sliceP, int samplePitchP, int sampleMax)
{ {
if(level == 0) if(level == 0)
{ {
...@@ -567,6 +570,16 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level, ...@@ -567,6 +570,16 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level,
mipmap.sliceP[1] = sliceP; mipmap.sliceP[1] = sliceP;
mipmap.sliceP[2] = sliceP; mipmap.sliceP[2] = sliceP;
mipmap.sliceP[3] = sliceP; mipmap.sliceP[3] = sliceP;
mipmap.samplePitchP[0] = samplePitchP;
mipmap.samplePitchP[1] = samplePitchP;
mipmap.samplePitchP[2] = samplePitchP;
mipmap.samplePitchP[3] = samplePitchP;
mipmap.sampleMax[0] = sampleMax;
mipmap.sampleMax[1] = sampleMax;
mipmap.sampleMax[2] = sampleMax;
mipmap.sampleMax[3] = sampleMax;
} }
void DescriptorSetLayout::WriteDescriptorSet(Device* device, const VkWriteDescriptorSet& writeDescriptorSet) void DescriptorSetLayout::WriteDescriptorSet(Device* device, const VkWriteDescriptorSet& writeDescriptorSet)
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
static void CopyDescriptorSet(const VkCopyDescriptorSet& descriptorCopies); static void CopyDescriptorSet(const VkCopyDescriptorSet& descriptorCopies);
static void WriteDescriptorSet(Device* device, DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src); static void WriteDescriptorSet(Device* device, DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src);
static void WriteTextureLevelInfo(sw::Texture *texture, int level, int width, int height, int depth, int pitchP, int sliceP); static void WriteTextureLevelInfo(sw::Texture *texture, int level, int width, int height, int depth, int pitchP, int sliceP, int samplePitchP, int sampleMax);
void initialize(DescriptorSet* descriptorSet); void initialize(DescriptorSet* descriptorSet);
......
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
bool is3DSlice() const; bool is3DSlice() const;
uint8_t* end() const; uint8_t* end() const;
VkDeviceSize getLayerSize(VkImageAspectFlagBits aspect) const; VkDeviceSize getLayerSize(VkImageAspectFlagBits aspect) const;
VkDeviceSize getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
bool canBindToMemory(DeviceMemory* pDeviceMemory) const; bool canBindToMemory(DeviceMemory* pDeviceMemory) const;
void prepareForSampling(const VkImageSubresourceRange& subresourceRange); void prepareForSampling(const VkImageSubresourceRange& subresourceRange);
...@@ -95,7 +96,6 @@ public: ...@@ -95,7 +96,6 @@ public:
private: private:
void copy(Buffer* buffer, const VkBufferImageCopy& region, bool bufferIsSource); void copy(Buffer* buffer, const VkBufferImageCopy& region, bool bufferIsSource);
VkDeviceSize getStorageSize(VkImageAspectFlags flags) const; VkDeviceSize getStorageSize(VkImageAspectFlags flags) const;
VkDeviceSize getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
VkDeviceSize getMultiSampledLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const; VkDeviceSize getMultiSampledLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
VkDeviceSize getLayerOffset(VkImageAspectFlagBits aspect, uint32_t mipLevel) const; VkDeviceSize getLayerOffset(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
VkDeviceSize getMemoryOffset(VkImageAspectFlagBits aspect, uint32_t mipLevel) const; VkDeviceSize getMemoryOffset(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
......
...@@ -267,6 +267,11 @@ int ImageView::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel, ...@@ -267,6 +267,11 @@ int ImageView::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel,
return getImage(usage)->slicePitchBytes(aspect, subresourceRange.baseMipLevel + mipLevel); return getImage(usage)->slicePitchBytes(aspect, subresourceRange.baseMipLevel + mipLevel);
} }
int ImageView::getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage) const
{
return getImage(usage)->getMipLevelSize(aspect, subresourceRange.baseMipLevel + mipLevel);
}
int ImageView::layerPitchBytes(VkImageAspectFlagBits aspect, Usage usage) const int ImageView::layerPitchBytes(VkImageAspectFlagBits aspect, Usage usage) const
{ {
return static_cast<int>(getImage(usage)->getLayerSize(aspect)); return static_cast<int>(getImage(usage)->getLayerSize(aspect));
......
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
Format getFormat(VkImageAspectFlagBits aspect) const { return image->getFormat(aspect); } Format getFormat(VkImageAspectFlagBits aspect) const { return image->getFormat(aspect); }
int rowPitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage = RAW) const; int rowPitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage = RAW) const;
int slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage = RAW) const; int slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage = RAW) const;
int getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel, Usage usage = RAW) const;
int layerPitchBytes(VkImageAspectFlagBits aspect, Usage usage = RAW) const; int layerPitchBytes(VkImageAspectFlagBits aspect, Usage usage = RAW) const;
VkExtent3D getMipLevelExtent(uint32_t mipLevel) const; VkExtent3D getMipLevelExtent(uint32_t mipLevel) const;
......
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