Browse Source

[REFACTOR] Clear texture is now using views

Panagiotis Christopoulos Charitos 8 years ago
parent
commit
6b153a46a9

+ 3 - 18
src/anki/gr/CommandBuffer.h

@@ -315,24 +315,9 @@ public:
 		TexturePtr src, const TextureVolumeInfo& srcVol, TexturePtr dest, const TextureVolumeInfo& destVol);
 
 	/// Clear a single texture surface. Can be used for all textures except 3D.
-	/// @param tex The texture to clear.
-	/// @param surf The surface to clear.
-	/// @param clearValue The value to clear it with.
-	/// @param aspect The aspect of the depth stencil texture. Relevant only for depth stencil textures.
-	void clearTextureSurface(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		const ClearValue& clearValue,
-		DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE);
-
-	/// Clear a volume out of a 3D texture.
-	/// @param tex The texture to clear.
-	/// @param vol The volume to clear.
-	/// @param clearValue The value to clear it with.
-	/// @param aspect The aspect of the depth stencil texture. Relevant only for depth stencil textures.
-	void clearTextureVolume(TexturePtr tex,
-		const TextureVolumeInfo& vol,
-		const ClearValue& clearValue,
-		DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE);
+	/// @param[in,out] texView The texture view to clear.
+	/// @param[in] clearValue The value to clear it with.
+	void clearTextureView(TextureViewPtr texView, const ClearValue& clearValue);
 
 	/// Copy a buffer to a texture surface.
 	void copyBufferToTextureSurface(

+ 5 - 11
src/anki/gr/Common.h

@@ -213,12 +213,14 @@ public:
 
 	U8 _m_padding[1] = {0};
 
-	TextureSubresourceInfo() = default;
+	TextureSubresourceInfo(DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
+		: m_depthStencilAspect(aspect)
+	{
+	}
 
 	TextureSubresourceInfo(const TextureSubresourceInfo&) = default;
 
-	static TextureSubresourceInfo newFromSurface(
-		const TextureSurfaceInfo& surf, DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
+	TextureSubresourceInfo(const TextureSurfaceInfo& surf, DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
 	{
 		TextureSubresourceInfo out;
 		out.m_baseMipmap = surf.m_level;
@@ -228,14 +230,6 @@ public:
 		out.m_baseFace = surf.m_face;
 		out.m_faceCount = 1;
 		out.m_depthStencilAspect = aspect;
-		return out;
-	}
-
-	static TextureSubresourceInfo newFromFirstSurface(DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
-	{
-		TextureSubresourceInfo out;
-		out.m_depthStencilAspect = aspect;
-		return out;
 	}
 };
 

+ 7 - 9
src/anki/gr/RenderGraph.cpp

@@ -373,9 +373,8 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(
 				outAtt.m_storeOperation = inAtt.m_storeOperation;
 
 				// Create texture view
-				TextureViewInitInfo viewInit(m_ctx->m_rts[rtHandles[i].m_idx].m_texture,
-					TextureSubresourceInfo::newFromSurface(inAtt.m_surface),
-					"RenderGraph");
+				TextureViewInitInfo viewInit(
+					m_ctx->m_rts[rtHandles[i].m_idx].m_texture, TextureSubresourceInfo(inAtt.m_surface), "RenderGraph");
 				TextureViewPtr view = getManager().newTextureView(viewInit);
 
 				outAtt.m_textureView = view;
@@ -394,7 +393,7 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(
 
 				// Create texture view
 				TextureViewInitInfo viewInit(m_ctx->m_rts[rtHandles[MAX_COLOR_ATTACHMENTS].m_idx].m_texture,
-					TextureSubresourceInfo::newFromSurface(inAtt.m_surface, inAtt.m_aspect),
+					TextureSubresourceInfo(inAtt.m_surface, inAtt.m_aspect),
 					"RenderGraph");
 				TextureViewPtr view = getManager().newTextureView(viewInit);
 
@@ -630,8 +629,7 @@ void RenderGraph::initRenderPassesAndSetDeps(const RenderGraphDescription& descr
 					{
 						getCrntUsage(graphicsPass.m_rtHandles[i],
 							passIdx,
-							TextureSubresourceInfo::newFromSurface(
-								graphicsPass.m_fbDescr.m_colorAttachments[i].m_surface),
+							TextureSubresourceInfo(graphicsPass.m_fbDescr.m_colorAttachments[i].m_surface),
 							usage);
 
 						outPass.m_colorUsages[i] = usage;
@@ -639,9 +637,9 @@ void RenderGraph::initRenderPassesAndSetDeps(const RenderGraphDescription& descr
 
 					if(!!graphicsPass.m_fbDescr.m_depthStencilAttachment.m_aspect)
 					{
-						TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromSurface(
-							graphicsPass.m_fbDescr.m_depthStencilAttachment.m_surface,
-							graphicsPass.m_fbDescr.m_depthStencilAttachment.m_aspect);
+						TextureSubresourceInfo subresource =
+							TextureSubresourceInfo(graphicsPass.m_fbDescr.m_depthStencilAttachment.m_surface,
+								graphicsPass.m_fbDescr.m_depthStencilAttachment.m_aspect);
 
 						getCrntUsage(graphicsPass.m_rtHandles[MAX_COLOR_ATTACHMENTS], passIdx, subresource, usage);
 

+ 2 - 10
src/anki/gr/vulkan/CommandBuffer.cpp

@@ -282,18 +282,10 @@ void CommandBuffer::copyTextureVolumeToTextureVolume(
 	ANKI_ASSERT(!"TODO");
 }
 
-void CommandBuffer::clearTextureSurface(
-	TexturePtr tex, const TextureSurfaceInfo& surf, const ClearValue& clearValue, DepthStencilAspectBit aspect)
+void CommandBuffer::clearTextureView(TextureViewPtr texView, const ClearValue& clearValue)
 {
 	ANKI_VK_SELF(CommandBufferImpl);
-	self.clearTextureSurface(tex, surf, clearValue, aspect);
-}
-
-void CommandBuffer::clearTextureVolume(
-	TexturePtr tex, const TextureVolumeInfo& vol, const ClearValue& clearValue, DepthStencilAspectBit aspect)
-{
-	ANKI_VK_SELF(CommandBufferImpl);
-	self.clearTextureVolume(tex, vol, clearValue, aspect);
+	self.clearTextureView(texView, clearValue);
 }
 
 void CommandBuffer::copyBufferToTextureSurface(

+ 1 - 7
src/anki/gr/vulkan/CommandBufferImpl.h

@@ -271,11 +271,7 @@ public:
 
 	void generateMipmaps2d(TexturePtr tex, U face, U layer);
 
-	void clearTextureSurface(
-		TexturePtr tex, const TextureSurfaceInfo& surf, const ClearValue& clearValue, DepthStencilAspectBit aspect);
-
-	void clearTextureVolume(
-		TexturePtr tex, const TextureVolumeInfo& volume, const ClearValue& clearValue, DepthStencilAspectBit aspect);
+	void clearTextureView(TextureViewPtr texView, const ClearValue& clearValue);
 
 	void pushSecondLevelCommandBuffer(CommandBufferPtr cmdb);
 
@@ -454,8 +450,6 @@ private:
 
 	void flushWriteQueryResults();
 
-	void clearTextureInternal(TexturePtr tex, const ClearValue& clearValue, const VkImageSubresourceRange& range);
-
 	void setImageBarrier(VkPipelineStageFlags srcStage,
 		VkAccessFlags srcAccess,
 		VkImageLayout prevLayout,

+ 10 - 30
src/anki/gr/vulkan/CommandBufferImpl.inl.h

@@ -398,50 +398,30 @@ inline void CommandBufferImpl::endOcclusionQuery(OcclusionQueryPtr query)
 	m_microCmdb->pushObjectRef(query);
 }
 
-inline void CommandBufferImpl::clearTextureInternal(
-	TexturePtr tex, const ClearValue& clearValue, const VkImageSubresourceRange& range)
+inline void CommandBufferImpl::clearTextureView(TextureViewPtr texView, const ClearValue& clearValue)
 {
 	commandCommon();
 
+	const TextureViewImpl& view = static_cast<const TextureViewImpl&>(*texView);
+	const TextureImpl& tex = static_cast<const TextureImpl&>(*view.m_tex);
+
 	VkClearColorValue vclear;
 	static_assert(sizeof(vclear) == sizeof(clearValue), "See file");
 	memcpy(&vclear, &clearValue, sizeof(clearValue));
 
-	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
-	if(!impl.m_aspect)
+	if(!view.getDepthStencilAspect())
 	{
-		ANKI_CMD(vkCmdClearColorImage(
-					 m_handle, impl.m_imageHandle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &vclear, 1, &range),
+		ANKI_CMD(
+			vkCmdClearColorImage(
+				m_handle, tex.m_imageHandle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &vclear, 1, &view.m_vkSubresource),
 			ANY_OTHER_COMMAND);
 	}
 	else
 	{
-		ANKI_ASSERT(0 && "TODO");
+		ANKI_ASSERT(!"TODO");
 	}
 
-	m_microCmdb->pushObjectRef(tex);
-}
-
-inline void CommandBufferImpl::clearTextureSurface(
-	TexturePtr tex, const TextureSurfaceInfo& surf, const ClearValue& clearValue, DepthStencilAspectBit aspect)
-{
-	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
-	ANKI_ASSERT(impl.getTextureType() != TextureType::_3D && "Not for 3D");
-
-	VkImageSubresourceRange range;
-	impl.computeSubResourceRange(surf, aspect, range);
-	clearTextureInternal(tex, clearValue, range);
-}
-
-inline void CommandBufferImpl::clearTextureVolume(
-	TexturePtr tex, const TextureVolumeInfo& vol, const ClearValue& clearValue, DepthStencilAspectBit aspect)
-{
-	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
-	ANKI_ASSERT(impl.getTextureType() == TextureType::_3D && "Only for 3D");
-
-	VkImageSubresourceRange range;
-	impl.computeSubResourceRange(vol, aspect, range);
-	clearTextureInternal(tex, clearValue, range);
+	m_microCmdb->pushObjectRef(texView);
 }
 
 inline void CommandBufferImpl::pushSecondLevelCommandBuffer(CommandBufferPtr cmdb)

+ 1 - 0
src/anki/gr/vulkan/TextureViewImpl.cpp

@@ -58,6 +58,7 @@ Error TextureViewImpl::init(const TextureViewInitInfo& inf)
 	Array<U64, 2> toHash = {{tex.getUuid(), ptrToNumber(m_handle)}};
 	m_hash = computeHash(&toHash[0], sizeof(toHash));
 
+	m_vkSubresource = viewCi.subresourceRange;
 	return Error::NONE;
 }
 

+ 1 - 0
src/anki/gr/vulkan/TextureViewImpl.h

@@ -21,6 +21,7 @@ public:
 	VkImageView m_handle = {};
 	TexturePtr m_tex; ///< Hold a reference.
 	TextureSubresourceInfo m_subresource;
+	VkImageSubresourceRange m_vkSubresource;
 
 	/// This is a hash that depends on the Texture and the VkImageView. It's used as a replacement of
 	/// TextureView::m_uuid since it creates less unique IDs.

+ 2 - 2
src/anki/renderer/DepthDownscale.cpp

@@ -114,7 +114,7 @@ void DepthDownscale::runHalf(RenderPassWorkContext& rgraphCtx)
 	rgraphCtx.bindTextureAndSampler(0,
 		0,
 		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
 		m_r->getLinearSampler());
 
 	cmdb->setViewport(0, 0, m_r->getWidth() / 2, m_r->getHeight() / 2);
@@ -153,7 +153,7 @@ void DepthDownscale::populateRenderGraph(RenderingContext& ctx)
 		pass.setFramebufferInfo(m_half.m_fbDescr, {{m_runCtx.m_halfColorRt}}, m_runCtx.m_halfDepthRt);
 		pass.setWork(runHalfCallback, this, 0);
 
-		TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH);
+		TextureSubresourceInfo subresource = TextureSubresourceInfo(DepthStencilAspectBit::DEPTH);
 
 		pass.newConsumer({m_r->getGBuffer().getDepthRt(), TextureUsageBit::SAMPLED_FRAGMENT, subresource});
 		pass.newConsumer({m_runCtx.m_halfColorRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});

+ 2 - 2
src/anki/renderer/ForwardShading.cpp

@@ -137,7 +137,7 @@ void ForwardShading::drawUpscale(const RenderingContext& ctx, RenderPassWorkCont
 	rgraphCtx.bindTextureAndSampler(0,
 		0,
 		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
 		m_r->getNearestSampler());
 	rgraphCtx.bindColorTextureAndSampler(
 		0, 1, m_r->getDepthDownscale().getHalfDepthColorRt(), m_r->getNearestSampler());
@@ -225,7 +225,7 @@ void ForwardShading::populateRenderGraph(RenderingContext& ctx)
 	pass.newConsumer({m_runCtx.m_rt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE});
 	pass.newConsumer({m_r->getDepthDownscale().getHalfDepthDepthRt(),
 		TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ,
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH)});
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 	pass.newConsumer({m_r->getDepthDownscale().getHalfDepthColorRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_r->getDepthDownscale().getQuarterColorRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_r->getVolumetric().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});

+ 1 - 1
src/anki/renderer/GBuffer.cpp

@@ -169,7 +169,7 @@ void GBuffer::populateRenderGraph(RenderingContext& ctx)
 		pass.newProducer({m_colorRts[i], TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});
 	}
 
-	TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH);
+	TextureSubresourceInfo subresource(DepthStencilAspectBit::DEPTH);
 	pass.newConsumer({m_depthRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 	pass.newProducer({m_depthRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 }

+ 7 - 12
src/anki/renderer/Indirect.cpp

@@ -456,7 +456,7 @@ void Indirect::runLightShading(U32 faceIdx, RenderPassWorkContext& rgraphCtx)
 	rgraphCtx.bindTextureAndSampler(0,
 		GBUFFER_COLOR_ATTACHMENT_COUNT,
 		m_ctx.m_gbufferDepthRt,
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
 		m_r->getNearestSampler());
 	cmdb->setVertexAttribute(0, 0, PixelFormat(ComponentFormat::R32G32B32, TransformFormat::FLOAT), 0);
 	cmdb->setViewport(0, 0, m_lightShading.m_tileSize, m_lightShading.m_tileSize);
@@ -570,8 +570,7 @@ void Indirect::runMipmappingOfLightShading(U32 faceIdx, RenderPassWorkContext& r
 
 	TexturePtr texToBind;
 	TextureUsageBit usage;
-	rgraphCtx.getRenderTargetState(
-		m_ctx.m_lightShadingRt, TextureSubresourceInfo::newFromFirstSurface(), texToBind, usage);
+	rgraphCtx.getRenderTargetState(m_ctx.m_lightShadingRt, TextureSubresourceInfo(), texToBind, usage);
 
 	rgraphCtx.m_commandBuffer->generateMipmaps2d(texToBind, faceIdx, m_ctx.m_cacheEntryIdx);
 }
@@ -646,8 +645,7 @@ void Indirect::populateRenderGraph(RenderingContext& rctx)
 				pass.newProducer({m_ctx.m_gbufferColorRts[i], TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});
 			}
 
-			TextureSubresourceInfo subresource =
-				TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH);
+			TextureSubresourceInfo subresource(DepthStencilAspectBit::DEPTH);
 			pass.newConsumer({m_ctx.m_gbufferDepthRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 			pass.newProducer({m_ctx.m_gbufferDepthRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 		}
@@ -680,8 +678,7 @@ void Indirect::populateRenderGraph(RenderingContext& rctx)
 					{});
 				pass.setWork(callbacks[faceIdx], this, 0);
 
-				TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromSurface(
-					TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
+				TextureSubresourceInfo subresource(TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
 				pass.newConsumer({m_ctx.m_lightShadingRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 				pass.newProducer({m_ctx.m_lightShadingRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 
@@ -691,7 +688,7 @@ void Indirect::populateRenderGraph(RenderingContext& rctx)
 				}
 				pass.newConsumer({m_ctx.m_gbufferDepthRt,
 					TextureUsageBit::SAMPLED_FRAGMENT,
-					TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH)});
+					TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 			}
 		}
 
@@ -711,8 +708,7 @@ void Indirect::populateRenderGraph(RenderingContext& rctx)
 				GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass(passNames[faceIdx]);
 				pass.setWork(callbacks[faceIdx], this, 0);
 
-				TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromSurface(
-					TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
+				TextureSubresourceInfo subresource(TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
 				subresource.m_mipmapCount = m_lightShading.m_mipCount;
 
 				pass.newConsumer({m_ctx.m_lightShadingRt, TextureUsageBit::GENERATE_MIPMAPS, subresource});
@@ -747,8 +743,7 @@ void Indirect::populateRenderGraph(RenderingContext& rctx)
 
 				pass.newConsumer({m_ctx.m_lightShadingRt, TextureUsageBit::SAMPLED_FRAGMENT});
 
-				TextureSubresourceInfo subresource = TextureSubresourceInfo::newFromSurface(
-					TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
+				TextureSubresourceInfo subresource(TextureSurfaceInfo(0, 0, faceIdx, probeToUpdateCacheEntryIdx));
 				pass.newConsumer({m_ctx.m_irradianceRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 				pass.newProducer({m_ctx.m_irradianceRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 			}

+ 2 - 2
src/anki/renderer/LightShading.cpp

@@ -136,7 +136,7 @@ void LightShading::run(const RenderingContext& ctx, RenderPassWorkContext& rgrap
 	rgraphCtx.bindTextureAndSampler(1,
 		3,
 		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
 		m_r->getNearestSampler());
 	rgraphCtx.bindColorTextureAndSampler(1, 4, m_r->getSsao().getRt(), m_r->getLinearSampler());
 
@@ -217,7 +217,7 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
 	pass.newConsumer({m_r->getGBuffer().getColorRt(2), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_r->getGBuffer().getDepthRt(),
 		TextureUsageBit::SAMPLED_FRAGMENT,
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH)});
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 	pass.newConsumer({m_r->getSsao().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_r->getShadowMapping().getShadowmapRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_r->getIndirect().getReflectionRt(), TextureUsageBit::SAMPLED_FRAGMENT});

+ 5 - 10
src/anki/renderer/ShadowMapping.cpp

@@ -149,11 +149,8 @@ void ShadowMapping::runEsm(RenderPassWorkContext& rgraphCtx)
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 
 	cmdb->bindShaderProgram(m_esmResolveGrProg);
-	rgraphCtx.bindTextureAndSampler(0,
-		0,
-		m_scratchRt,
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
-		m_r->getLinearSampler());
+	rgraphCtx.bindTextureAndSampler(
+		0, 0, m_scratchRt, TextureSubresourceInfo(DepthStencilAspectBit::DEPTH), m_r->getLinearSampler());
 
 	for(const EsmResolveWorkItem& workItem : m_esmResolveWorkItems)
 	{
@@ -232,8 +229,7 @@ void ShadowMapping::populateRenderGraph(RenderingContext& ctx)
 				threadCountForScratchPass && threadCountForScratchPass <= m_r->getThreadPool().getThreadCount());
 			pass.setWork(runShadowmappingCallback, this, threadCountForScratchPass);
 
-			TextureSubresourceInfo subresource =
-				TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH);
+			TextureSubresourceInfo subresource = TextureSubresourceInfo(DepthStencilAspectBit::DEPTH);
 			pass.newConsumer({m_scratchRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 			pass.newProducer({m_scratchRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource});
 		}
@@ -246,9 +242,8 @@ void ShadowMapping::populateRenderGraph(RenderingContext& ctx)
 			pass.setFramebufferInfo(m_esmFbDescr, {{m_esmRt}}, {});
 			pass.setWork(runEsmCallback, this, 0);
 
-			pass.newConsumer({m_scratchRt,
-				TextureUsageBit::SAMPLED_FRAGMENT,
-				TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH)});
+			pass.newConsumer(
+				{m_scratchRt, TextureUsageBit::SAMPLED_FRAGMENT, TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 			pass.newConsumer({m_esmRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});
 			pass.newProducer({m_esmRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});
 		}

+ 2 - 2
src/anki/renderer/TemporalAA.cpp

@@ -77,7 +77,7 @@ void TemporalAA::run(const RenderingContext& ctx, RenderPassWorkContext& rgraphC
 	rgraphCtx.bindTextureAndSampler(0,
 		0,
 		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH),
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
 		m_r->getLinearSampler());
 	rgraphCtx.bindColorTextureAndSampler(0, 1, m_r->getLightShading().getRt(), m_r->getLinearSampler());
 	rgraphCtx.bindColorTextureAndSampler(0, 2, m_runCtx.m_historyRt, m_r->getLinearSampler());
@@ -110,7 +110,7 @@ void TemporalAA::populateRenderGraph(RenderingContext& ctx)
 	pass.newConsumer({m_runCtx.m_renderRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});
 	pass.newConsumer({m_r->getGBuffer().getDepthRt(),
 		TextureUsageBit::SAMPLED_FRAGMENT,
-		TextureSubresourceInfo::newFromFirstSurface(DepthStencilAspectBit::DEPTH)});
+		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 	pass.newConsumer({m_r->getLightShading().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newConsumer({m_runCtx.m_historyRt, TextureUsageBit::SAMPLED_FRAGMENT});
 

+ 19 - 17
tests/gr/Gr.cpp

@@ -584,10 +584,13 @@ ANKI_TEST(Gr, ViewportAndScissorOffscreen)
 	Array<FramebufferPtr, 4> fb;
 	for(FramebufferPtr& f : fb)
 	{
+		TextureViewInitInfo viewInf(rt);
+		TextureViewPtr view = gr->newTextureView(viewInf);
+
 		FramebufferInitInfo fbinit;
 		fbinit.m_colorAttachmentCount = 1;
 		fbinit.m_colorAttachments[0].m_clearValue.m_colorf = {{randFloat(1.0), randFloat(1.0), randFloat(1.0), 1.0}};
-		fbinit.m_colorAttachments[0].m_texture = rt;
+		fbinit.m_colorAttachments[0].m_textureView = view;
 
 		f = gr->newFramebuffer(fbinit);
 	}
@@ -1141,15 +1144,10 @@ static void drawOffscreen(GrManager& gr, Bool useSecondLevel)
 	const U TEX_SIZE = 256;
 
 	TextureInitInfo init;
-	init.m_depth = 1;
 	init.m_format = COL_FORMAT;
 	init.m_usage = TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE;
 	init.m_height = TEX_SIZE;
 	init.m_width = TEX_SIZE;
-	init.m_mipmapsCount = 1;
-	init.m_depth = 1;
-	init.m_layerCount = 1;
-	init.m_samples = 1;
 	init.m_type = TextureType::_2D;
 
 	TexturePtr col0 = gr.newTexture(init);
@@ -1163,12 +1161,13 @@ static void drawOffscreen(GrManager& gr, Bool useSecondLevel)
 	//
 	FramebufferInitInfo fbinit;
 	fbinit.m_colorAttachmentCount = 2;
-	fbinit.m_colorAttachments[0].m_texture = col0;
+	fbinit.m_colorAttachments[0].m_textureView = gr.newTextureView(TextureViewInitInfo(col0));
 	fbinit.m_colorAttachments[0].m_clearValue.m_colorf = {{0.1, 0.0, 0.0, 0.0}};
-	fbinit.m_colorAttachments[1].m_texture = col1;
+	fbinit.m_colorAttachments[1].m_textureView = gr.newTextureView(TextureViewInitInfo(col1));
 	fbinit.m_colorAttachments[1].m_clearValue.m_colorf = {{0.0, 0.1, 0.0, 0.0}};
-	fbinit.m_depthStencilAttachment.m_texture = dp;
-	fbinit.m_depthStencilAttachment.m_aspect = DepthStencilAspectBit::DEPTH;
+	TextureViewInitInfo viewInit(dp);
+	viewInit.m_depthStencilAspect = DepthStencilAspectBit::DEPTH;
+	fbinit.m_depthStencilAttachment.m_textureView = gr.newTextureView(viewInit);
 	fbinit.m_depthStencilAttachment.m_clearValue.m_depthStencil.m_depth = 1.0;
 
 	FramebufferPtr fb = gr.newFramebuffer(fbinit);
@@ -1336,7 +1335,8 @@ ANKI_TEST(Gr, ImageLoadStore)
 
 	ClearValue clear;
 	clear.m_colorf = {{0.0, 1.0, 0.0, 1.0}};
-	cmdb->clearTextureSurface(tex, TextureSurfaceInfo(0, 0, 0, 0), clear);
+	TextureViewInitInfo viewInit2(tex, TextureSurfaceInfo(0, 0, 0, 0));
+	cmdb->clearTextureView(gr->newTextureView(viewInit2), clear);
 
 	cmdb->setTextureSurfaceBarrier(
 		tex, TextureUsageBit::CLEAR, TextureUsageBit::SAMPLED_FRAGMENT, TextureSurfaceInfo(0, 0, 0, 0));
@@ -1344,7 +1344,8 @@ ANKI_TEST(Gr, ImageLoadStore)
 	cmdb->setTextureSurfaceBarrier(tex, TextureUsageBit::NONE, TextureUsageBit::CLEAR, TextureSurfaceInfo(1, 0, 0, 0));
 
 	clear.m_colorf = {{0.0, 0.0, 1.0, 1.0}};
-	cmdb->clearTextureSurface(tex, TextureSurfaceInfo(1, 0, 0, 0), clear);
+	TextureViewInitInfo viewInit3(tex, TextureSurfaceInfo(1, 0, 0, 0));
+	cmdb->clearTextureView(gr->newTextureView(viewInit3), clear);
 
 	cmdb->setTextureSurfaceBarrier(
 		tex, TextureUsageBit::CLEAR, TextureUsageBit::IMAGE_COMPUTE_WRITE, TextureSurfaceInfo(1, 0, 0, 0));
@@ -1360,7 +1361,8 @@ ANKI_TEST(Gr, ImageLoadStore)
 		gr->beginFrame();
 
 		CommandBufferInitInfo cinit;
-		cinit.m_flags = CommandBufferFlag::GRAPHICS_WORK | CommandBufferFlag::COMPUTE_WORK;
+		cinit.m_flags =
+			CommandBufferFlag::GRAPHICS_WORK | CommandBufferFlag::COMPUTE_WORK | CommandBufferFlag::SMALL_BATCH;
 		CommandBufferPtr cmdb = gr->newCommandBuffer(cinit);
 
 		// Write image
@@ -1616,16 +1618,16 @@ ANKI_TEST(Gr, RenderGraph)
 	RenderTargetHandle giGiLightRt = descr.importRenderTarget("GI light", dummyTex, TextureUsageBit::SAMPLED_FRAGMENT);
 	for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
 	{
+		TextureSubresourceInfo subresource(TextureSurfaceInfo(0, 0, faceIdx, 0));
+
 		GraphicsRenderPassDescription& pass =
 			descr.newGraphicsRenderPass(StringAuto(alloc).sprintf("GI lp%u", faceIdx).toCString());
-		pass.newConsumer(
-			{giGiLightRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, TextureSurfaceInfo(0, 0, faceIdx, 0)});
+		pass.newConsumer({giGiLightRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 		pass.newConsumer({giGbuffNormRt, TextureUsageBit::SAMPLED_FRAGMENT});
 		pass.newConsumer({giGbuffDepthRt, TextureUsageBit::SAMPLED_FRAGMENT});
 		pass.newConsumer({giGbuffDiffRt, TextureUsageBit::SAMPLED_FRAGMENT});
 
-		pass.newProducer(
-			{giGiLightRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, TextureSurfaceInfo(0, 0, faceIdx, 0)});
+		pass.newProducer({giGiLightRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE, subresource});
 	}
 
 	// GI light mips