Rename render target to color buffer

The Vulkan spec does not use the term 'render target' (except in
extensions that probably borrow it from other APIs). Instead is uses
'attachment', and distinguishes between color, depth, and stencil
attachments. Render target can be confused to just refer to color
attachments, or any buffer that can be rendered to by the graphics
pipeline.

While the term 'color buffer' isn't used much either in the Vulkan spec,
the term 'depth buffer' is. Also, color buffer was the term used in the
OpenGL spec for color framebuffer attachments. Thus its meaning should
be well understood, or at least better than 'render target'.

Bug: b/134584057
Change-Id: I9ccc898ac98b99a9ab86098a465ab8331719cb66
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/57070
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Sean Risser <srisser@google.com>
diff --git a/src/Device/Config.hpp b/src/Device/Config.hpp
index 8f5adef..0fd38ed 100644
--- a/src/Device/Config.hpp
+++ b/src/Device/Config.hpp
@@ -29,7 +29,7 @@
 	MIN_TEXEL_OFFSET = -8,
 	MAX_TEXEL_OFFSET = 7,
 	MAX_TEXTURE_LOD = MIPMAP_LEVELS - 2,  // Trilinear accesses lod+1
-	RENDERTARGETS = 8,
+	MAX_COLOR_BUFFERS = 8,
 	MAX_INTERFACE_COMPONENTS = 32 * 4,  // Must be multiple of 4 for 16-byte alignment.
 	MAX_FRAMEBUFFER_DIM = OUTLINE_RESOLUTION,
 	MAX_VIEWPORT_DIM = MAX_FRAMEBUFFER_DIM,
diff --git a/src/Device/Context.cpp b/src/Device/Context.cpp
index fd0964e..28ef706 100644
--- a/src/Device/Context.cpp
+++ b/src/Device/Context.cpp
@@ -13,6 +13,7 @@
 // limitations under the License.
 
 #include "Context.hpp"
+
 #include "Vulkan/VkBuffer.hpp"
 #include "Vulkan/VkDevice.hpp"
 #include "Vulkan/VkImageView.hpp"
@@ -137,7 +138,7 @@
 
 bool Attachments::isColorClamped(int index) const
 {
-	if(renderTarget[index] && renderTarget[index]->getFormat().isFloatFormat())
+	if(colorBuffer[index] && colorBuffer[index]->getFormat().isFloatFormat())
 	{
 		return false;
 	}
@@ -145,13 +146,13 @@
 	return true;
 }
 
-VkFormat Attachments::renderTargetInternalFormat(int index) const
+VkFormat Attachments::colorFormat(int index) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
-	if(renderTarget[index])
+	if(colorBuffer[index])
 	{
-		return renderTarget[index]->getFormat();
+		return colorBuffer[index]->getFormat();
 	}
 	else
 	{
@@ -453,7 +454,7 @@
 		const vk::RenderPass *renderPass = vk::Cast(pCreateInfo->renderPass);
 		const VkSubpassDescription &subpass = renderPass->getSubpass(pCreateInfo->subpass);
 
-		//  Ignore pDepthStencilState when "the subpass of the render pass the pipeline is created against does not use a depth/stencil attachment"
+		// Ignore pDepthStencilState when "the subpass of the render pass the pipeline is created against does not use a depth/stencil attachment"
 		if(subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
 		{
 			if(depthStencilState->flags != 0)
@@ -510,7 +511,7 @@
 				blendConstants.w = colorBlendState->blendConstants[3];
 			}
 
-			ASSERT(colorBlendState->attachmentCount <= sw::RENDERTARGETS);
+			ASSERT(colorBlendState->attachmentCount <= sw::MAX_COLOR_BUFFERS);
 			for(auto i = 0u; i < colorBlendState->attachmentCount; i++)
 			{
 				const VkPipelineColorBlendAttachmentState &attachment = colorBlendState->pAttachments[i];
@@ -657,7 +658,7 @@
 
 BlendState GraphicsState::getBlendState(int index, const Attachments &attachments, bool fragmentContainsKill) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	BlendState activeBlendState;
 	activeBlendState.alphaBlendEnable = alphaBlendActive(index, attachments, fragmentContainsKill);
@@ -672,7 +673,7 @@
 
 bool GraphicsState::alphaBlendActive(int index, const Attachments &attachments, bool fragmentContainsKill) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	if(!blendState[index].alphaBlendEnable)
 	{
@@ -694,7 +695,7 @@
 
 VkBlendFactor GraphicsState::sourceBlendFactor(int index) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	if(!blendState[index].alphaBlendEnable) return VK_BLEND_FACTOR_ONE;
 
@@ -717,7 +718,7 @@
 
 VkBlendFactor GraphicsState::destBlendFactor(int index) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	if(!blendState[index].alphaBlendEnable) return VK_BLEND_FACTOR_ONE;
 
@@ -740,7 +741,7 @@
 
 VkBlendOp GraphicsState::blendOperation(int index, const Attachments &attachments) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	if(!blendState[index].alphaBlendEnable) return VK_BLEND_OP_SRC_EXT;
 
@@ -854,7 +855,7 @@
 
 VkBlendFactor GraphicsState::sourceBlendFactorAlpha(int index) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	switch(blendState[index].blendOperationAlpha)
 	{
@@ -875,7 +876,7 @@
 
 VkBlendFactor GraphicsState::destBlendFactorAlpha(int index) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	switch(blendState[index].blendOperationAlpha)
 	{
@@ -896,7 +897,7 @@
 
 VkBlendOp GraphicsState::blendOperationAlpha(int index, const Attachments &attachments) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
 	switch(blendState[index].blendOperationAlpha)
 	{
@@ -1008,7 +1009,7 @@
 
 bool GraphicsState::colorWriteActive(const Attachments &attachments) const
 {
-	for(int i = 0; i < sw::RENDERTARGETS; i++)
+	for(int i = 0; i < sw::MAX_COLOR_BUFFERS; i++)
 	{
 		if(colorWriteActive(i, attachments))
 		{
@@ -1021,9 +1022,9 @@
 
 int GraphicsState::colorWriteActive(int index, const Attachments &attachments) const
 {
-	ASSERT((index >= 0) && (index < sw::RENDERTARGETS));
+	ASSERT((index >= 0) && (index < sw::MAX_COLOR_BUFFERS));
 
-	if(!attachments.renderTarget[index] || attachments.renderTarget[index]->getFormat() == VK_FORMAT_UNDEFINED)
+	if(!attachments.colorBuffer[index] || attachments.colorBuffer[index]->getFormat() == VK_FORMAT_UNDEFINED)
 	{
 		return 0;
 	}
diff --git a/src/Device/Context.hpp b/src/Device/Context.hpp
index d9475cd..c85475b 100644
--- a/src/Device/Context.hpp
+++ b/src/Device/Context.hpp
@@ -51,12 +51,12 @@
 
 struct Attachments
 {
-	ImageView *renderTarget[sw::RENDERTARGETS] = {};
+	ImageView *colorBuffer[sw::MAX_COLOR_BUFFERS] = {};
 	ImageView *depthBuffer = nullptr;
 	ImageView *stencilBuffer = nullptr;
 
 	bool isColorClamped(int index) const;
-	VkFormat renderTargetInternalFormat(int index) const;
+	VkFormat colorFormat(int index) const;
 };
 
 struct Inputs
@@ -239,7 +239,7 @@
 
 	float lineWidth = 0.0f;
 
-	int colorWriteMask[sw::RENDERTARGETS] = {};  // RGBA
+	int colorWriteMask[sw::MAX_COLOR_BUFFERS] = {};  // RGBA
 	unsigned int multiSampleMask = 0;
 	int sampleCount = 0;
 	bool alphaToCoverage = false;
@@ -252,7 +252,7 @@
 	VkViewport viewport = {};
 	sw::float4 blendConstants = {};
 
-	BlendState blendState[sw::RENDERTARGETS] = {};
+	BlendState blendState[sw::MAX_COLOR_BUFFERS] = {};
 };
 
 }  // namespace vk
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index a3e96b9..6137722 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -143,10 +143,10 @@
 	state.occlusionEnabled = occlusionEnabled;
 
 	bool fragmentContainsKill = (fragmentShader && fragmentShader->getAnalysis().ContainsKill);
-	for(int i = 0; i < RENDERTARGETS; i++)
+	for(int i = 0; i < MAX_COLOR_BUFFERS; i++)
 	{
 		state.colorWriteMask |= pipelineState.colorWriteActive(i, attachments) << (4 * i);
-		state.targetFormat[i] = attachments.renderTargetInternalFormat(i);
+		state.colorFormat[i] = attachments.colorFormat(i);
 		state.blendState[i] = pipelineState.getBlendState(i, attachments, fragmentContainsKill);
 	}
 
diff --git a/src/Device/PixelProcessor.hpp b/src/Device/PixelProcessor.hpp
index c07366b..6c93e95 100644
--- a/src/Device/PixelProcessor.hpp
+++ b/src/Device/PixelProcessor.hpp
@@ -81,10 +81,10 @@
 		bool occlusionEnabled;
 		bool perspective;
 
-		vk::BlendState blendState[RENDERTARGETS];
+		vk::BlendState blendState[MAX_COLOR_BUFFERS];
 
 		unsigned int colorWriteMask;
-		vk::Format targetFormat[RENDERTARGETS];
+		vk::Format colorFormat[MAX_COLOR_BUFFERS];
 		unsigned int multiSampleCount;
 		unsigned int multiSampleMask;
 		bool enableMultiSampling;
diff --git a/src/Device/QuadRasterizer.cpp b/src/Device/QuadRasterizer.cpp
index 6c5397c..a0f0272 100644
--- a/src/Device/QuadRasterizer.cpp
+++ b/src/Device/QuadRasterizer.cpp
@@ -69,13 +69,13 @@
 
 void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
 {
-	Pointer<Byte> cBuffer[RENDERTARGETS];
+	Pointer<Byte> cBuffer[MAX_COLOR_BUFFERS];
 	Pointer<Byte> zBuffer;
 	Pointer<Byte> sBuffer;
 
 	Int clusterCountLog2 = 31 - Ctlz(UInt(clusterCount), false);
 
-	for(int index = 0; index < RENDERTARGETS; index++)
+	for(int index = 0; index < MAX_COLOR_BUFFERS; index++)
 	{
 		if(state.colorWriteActive(index))
 		{
@@ -204,7 +204,7 @@
 			}
 		}
 
-		for(int index = 0; index < RENDERTARGETS; index++)
+		for(int index = 0; index < MAX_COLOR_BUFFERS; index++)
 		{
 			if(state.colorWriteActive(index))
 			{
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index ca15e11..a3002a5 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -380,15 +380,15 @@
 	{
 		const vk::Attachments attachments = pipeline->getAttachments();
 
-		for(int index = 0; index < RENDERTARGETS; index++)
+		for(int index = 0; index < MAX_COLOR_BUFFERS; index++)
 		{
-			draw->renderTarget[index] = attachments.renderTarget[index];
+			draw->colorBuffer[index] = attachments.colorBuffer[index];
 
-			if(draw->renderTarget[index])
+			if(draw->colorBuffer[index])
 			{
-				data->colorBuffer[index] = (unsigned int *)attachments.renderTarget[index]->getOffsetPointer({ 0, 0, 0 }, VK_IMAGE_ASPECT_COLOR_BIT, 0, data->viewID);
-				data->colorPitchB[index] = attachments.renderTarget[index]->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
-				data->colorSliceB[index] = attachments.renderTarget[index]->slicePitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
+				data->colorBuffer[index] = (unsigned int *)attachments.colorBuffer[index]->getOffsetPointer({ 0, 0, 0 }, VK_IMAGE_ASPECT_COLOR_BIT, 0, data->viewID);
+				data->colorPitchB[index] = attachments.colorBuffer[index]->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
+				data->colorSliceB[index] = attachments.colorBuffer[index]->slicePitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
 			}
 		}
 
@@ -466,11 +466,11 @@
 	setupRoutine = {};
 	pixelRoutine = {};
 
-	for(auto *rt : renderTarget)
+	for(auto *target : colorBuffer)
 	{
-		if(rt)
+		if(target)
 		{
-			rt->contentsChanged();
+			target->contentsChanged();
 		}
 	}
 
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp
index 0252ed7..9d550ad 100644
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -95,9 +95,9 @@
 	float depthBiasClamp;
 	bool depthClipEnable;
 
-	unsigned int *colorBuffer[RENDERTARGETS];
-	int colorPitchB[RENDERTARGETS];
-	int colorSliceB[RENDERTARGETS];
+	unsigned int *colorBuffer[MAX_COLOR_BUFFERS];
+	int colorPitchB[MAX_COLOR_BUFFERS];
+	int colorSliceB[MAX_COLOR_BUFFERS];
 	float *depthBuffer;
 	int depthPitchB;
 	int depthSliceB;
@@ -170,7 +170,7 @@
 	SetupProcessor::State setupState;
 
 	vk::Device *device;
-	vk::ImageView *renderTarget[RENDERTARGETS];
+	vk::ImageView *colorBuffer[MAX_COLOR_BUFFERS];
 	vk::ImageView *depthBuffer;
 	vk::ImageView *stencilBuffer;
 	vk::DescriptorSet::Array descriptorSetObjects;
diff --git a/src/Pipeline/PixelProgram.cpp b/src/Pipeline/PixelProgram.cpp
index 3c6d136..42ce095 100644
--- a/src/Pipeline/PixelProgram.cpp
+++ b/src/Pipeline/PixelProgram.cpp
@@ -206,7 +206,7 @@
 		spirvShader->clearPhis(&routine);
 	}
 
-	for(int i = 0; i < RENDERTARGETS; i++)
+	for(int i = 0; i < MAX_COLOR_BUFFERS; i++)
 	{
 		c[i].x = routine.outputs[i * 4];
 		c[i].y = routine.outputs[i * 4 + 1];
@@ -274,14 +274,14 @@
 
 void PixelProgram::rasterOperation(Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4], const SampleSet &samples)
 {
-	for(int index = 0; index < RENDERTARGETS; index++)
+	for(int index = 0; index < MAX_COLOR_BUFFERS; index++)
 	{
 		if(!state.colorWriteActive(index))
 		{
 			continue;
 		}
 
-		auto format = state.targetFormat[index];
+		auto format = state.colorFormat[index];
 		switch(format)
 		{
 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
@@ -356,16 +356,16 @@
 	}
 }
 
-void PixelProgram::clampColor(Vector4f oC[RENDERTARGETS])
+void PixelProgram::clampColor(Vector4f oC[MAX_COLOR_BUFFERS])
 {
-	for(int index = 0; index < RENDERTARGETS; index++)
+	for(int index = 0; index < MAX_COLOR_BUFFERS; index++)
 	{
 		if(!state.colorWriteActive(index) && !(index == 0 && state.alphaToCoverage))
 		{
 			continue;
 		}
 
-		switch(state.targetFormat[index])
+		switch(state.colorFormat[index])
 		{
 		case VK_FORMAT_UNDEFINED:
 			break;
@@ -423,7 +423,7 @@
 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
 			break;
 		default:
-			UNSUPPORTED("VkFormat: %d", int(state.targetFormat[index]));
+			UNSUPPORTED("VkFormat: %d", int(state.colorFormat[index]));
 		}
 	}
 }
diff --git a/src/Pipeline/PixelProgram.hpp b/src/Pipeline/PixelProgram.hpp
index 306c3da..dfdd1f1 100644
--- a/src/Pipeline/PixelProgram.hpp
+++ b/src/Pipeline/PixelProgram.hpp
@@ -38,10 +38,10 @@
 
 private:
 	// Color outputs
-	Vector4f c[RENDERTARGETS];
+	Vector4f c[MAX_COLOR_BUFFERS];
 
 	// Raster operations
-	void clampColor(Vector4f oC[RENDERTARGETS]);
+	void clampColor(Vector4f oC[MAX_COLOR_BUFFERS]);
 
 	static Int4 maskAny(Int cMask[4], const SampleSet &samples);
 	static Int4 maskAny(Int cMask[4], Int sMask[4], Int zMask[4], const SampleSet &samples);
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index 019477b..ef9bd1c 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -51,7 +51,7 @@
 		}
 	}
 
-	for(int i = 0; i < RENDERTARGETS; i++)
+	for(int i = 0; i < MAX_COLOR_BUFFERS; i++)
 	{
 		outputMasks[i] = 0xF;
 	}
@@ -79,7 +79,7 @@
 	return samples;
 }
 
-void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y)
+void PixelRoutine::quad(Pointer<Byte> cBuffer[MAX_COLOR_BUFFERS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y)
 {
 	const bool earlyFragmentTests = !spirvShader || spirvShader->getExecutionModes().EarlyFragmentTests;
 
@@ -1040,7 +1040,7 @@
 
 bool PixelRoutine::isSRGB(int index) const
 {
-	return vk::Format(state.targetFormat[index]).isSRGBformat();
+	return vk::Format(state.colorFormat[index]).isSRGBformat();
 }
 
 void PixelRoutine::readPixel(int index, const Pointer<Byte> &cBuffer, const Int &x, Vector4s &pixel)
@@ -1052,7 +1052,7 @@
 
 	Int pitchB = *Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index]));
 
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
 		buffer += 2 * x;
@@ -1199,7 +1199,7 @@
 		}
 		break;
 	default:
-		UNSUPPORTED("VkFormat %d", int(state.targetFormat[index]));
+		UNSUPPORTED("VkFormat %d", int(state.colorFormat[index]));
 	}
 
 	if(isSRGB(index))
@@ -1215,7 +1215,7 @@
 		return;
 	}
 
-	ASSERT(state.targetFormat[index].supportsColorAttachmentBlend());
+	ASSERT(state.colorFormat[index].supportsColorAttachmentBlend());
 
 	Vector4s pixel;
 	readPixel(index, cBuffer, x, pixel);
@@ -1336,7 +1336,7 @@
 		linearToSRGB16_12_16(current);
 	}
 
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_B8G8R8A8_UNORM:
 	case VK_FORMAT_B8G8R8A8_SRGB:
@@ -1376,7 +1376,7 @@
 	int rgbaWriteMask = state.colorWriteActive(index) & outputMasks[index];
 	int bgraWriteMask = (rgbaWriteMask & 0x0000000A) | (rgbaWriteMask & 0x00000001) << 2 | (rgbaWriteMask & 0x00000004) >> 2;
 
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
 		{
@@ -1518,7 +1518,7 @@
 		}
 		break;
 	default:
-		UNSUPPORTED("VkFormat: %d", int(state.targetFormat[index]));
+		UNSUPPORTED("VkFormat: %d", int(state.colorFormat[index]));
 	}
 
 	Short4 c01 = current.z;
@@ -1543,7 +1543,7 @@
 	Pointer<Byte> buffer = cBuffer;
 	Int pitchB = *Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index]));
 
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
 		{
@@ -1830,7 +1830,7 @@
 		}
 		break;
 	default:
-		UNSUPPORTED("VkFormat: %d", int(state.targetFormat[index]));
+		UNSUPPORTED("VkFormat: %d", int(state.colorFormat[index]));
 	}
 }
 
@@ -1977,7 +1977,7 @@
 		return;
 	}
 
-	vk::Format format = state.targetFormat[index];
+	vk::Format format = state.colorFormat[index];
 	ASSERT(format.supportsColorAttachmentBlend());
 
 	Pointer<Byte> buffer = cBuffer;
@@ -2003,7 +2003,7 @@
 		one = As<Float4>(format.isUnsignedComponent(0) ? Int4(0xFFFFFFFF) : Int4(0x7FFFFFFF));
 	}
 
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_R32_SINT:
 	case VK_FORMAT_R32_UINT:
@@ -2095,7 +2095,7 @@
 		pixel.w = one;
 		break;
 	default:
-		UNSUPPORTED("VkFormat: %d", int(state.targetFormat[index]));
+		UNSUPPORTED("VkFormat: %d", int(state.colorFormat[index]));
 	}
 
 	// Final Color = ObjectColor * SourceBlendFactor + PixelColor * DestinationBlendFactor
@@ -2202,7 +2202,7 @@
 
 void PixelRoutine::writeColor(int index, const Pointer<Byte> &cBuffer, const Int &x, Vector4f &oC, const Int &sMask, const Int &zMask, const Int &cMask)
 {
-	switch(state.targetFormat[index])
+	switch(state.colorFormat[index])
 	{
 	case VK_FORMAT_R16_SFLOAT:
 	case VK_FORMAT_R32_SFLOAT:
@@ -2242,7 +2242,7 @@
 		transpose4x4(oC.x, oC.y, oC.z, oC.w);
 		break;
 	default:
-		UNSUPPORTED("VkFormat: %d", int(state.targetFormat[index]));
+		UNSUPPORTED("VkFormat: %d", int(state.colorFormat[index]));
 	}
 
 	int rgbaWriteMask = state.colorWriteActive(index) & outputMasks[index];
@@ -2264,13 +2264,13 @@
 		xMask &= sMask;
 	}
 
-	auto targetFormat = state.targetFormat[index];
+	auto colorFormat = state.colorFormat[index];
 
 	Pointer<Byte> buffer = cBuffer;
 	Int pitchB = *Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index]));
 	Float4 value;
 
-	switch(targetFormat)
+	switch(colorFormat)
 	{
 	case VK_FORMAT_R32_SFLOAT:
 	case VK_FORMAT_R32_SINT:
@@ -2348,7 +2348,7 @@
 			value = As<Float4>(As<Int4>(value) & *Pointer<Int4>(constants + OFFSET(Constants, invMaskD4X) + xMask * 16, 16));
 			oC.x = As<Float4>(As<Int4>(oC.x) | As<Int4>(value));
 
-			if(targetFormat == VK_FORMAT_R16_SINT)
+			if(colorFormat == VK_FORMAT_R16_SINT)
 			{
 				Float component = oC.x.z;
 				*Pointer<Short>(buffer + 0) = Short(As<Int>(component));
@@ -2391,7 +2391,7 @@
 			xyzw |= UInt(*Pointer<UShort>(buffer)) << 16;
 
 			Short4 tmpCol = Short4(As<Int4>(oC.x));
-			if(targetFormat == VK_FORMAT_R8_SINT)
+			if(colorFormat == VK_FORMAT_R8_SINT)
 			{
 				tmpCol = As<Short4>(PackSigned(tmpCol, tmpCol));
 			}
@@ -2523,7 +2523,7 @@
 			buffer += pitchB;
 			xyzw = Insert(xyzw, *Pointer<Int>(buffer), 1);
 
-			if(targetFormat == VK_FORMAT_R8G8_SINT)
+			if(colorFormat == VK_FORMAT_R8G8_SINT)
 			{
 				packedCol = As<Int2>(PackSigned(Short4(As<Int4>(oC.x)), Short4(As<Int4>(oC.y))));
 			}
@@ -2730,7 +2730,7 @@
 
 			buffer += 4 * x;
 
-			bool isSigned = targetFormat == VK_FORMAT_R8G8B8A8_SINT || targetFormat == VK_FORMAT_A8B8G8R8_SINT_PACK32;
+			bool isSigned = colorFormat == VK_FORMAT_R8G8B8A8_SINT || colorFormat == VK_FORMAT_A8B8G8R8_SINT_PACK32;
 
 			if(isSigned)
 			{
@@ -2826,7 +2826,7 @@
 		}
 		break;
 	default:
-		UNSUPPORTED("VkFormat: %d", int(targetFormat));
+		UNSUPPORTED("VkFormat: %d", int(colorFormat));
 	}
 }
 
diff --git a/src/Pipeline/PixelRoutine.hpp b/src/Pipeline/PixelRoutine.hpp
index c1e6c0c..c07689f 100644
--- a/src/Pipeline/PixelRoutine.hpp
+++ b/src/Pipeline/PixelRoutine.hpp
@@ -41,7 +41,7 @@
 	Float4 w;     // Used as is
 	Float4 rhw;   // Reciprocal w
 
-	uint32_t outputMasks[RENDERTARGETS];  // TODO(b/162348737): Determine whether unwritten output should be left untouched
+	uint32_t outputMasks[MAX_COLOR_BUFFERS];  // TODO(b/162348737): Determine whether unwritten output should be left untouched
 
 	SpirvRoutine routine;
 	const vk::DescriptorSet::Bindings &descriptorSets;
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index 395e26c..9ca3cf1 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -1768,7 +1768,7 @@
 		auto attachmentReference = subpass.pColorAttachments[i];
 		if(attachmentReference.attachment != VK_ATTACHMENT_UNUSED)
 		{
-			attachments->renderTarget[i] = renderPassFramebuffer->getAttachment(attachmentReference.attachment);
+			attachments->colorBuffer[i] = renderPassFramebuffer->getAttachment(attachmentReference.attachment);
 		}
 	}
 
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 9a42c3c..7cbe047 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -441,73 +441,73 @@
 	VkSampleCountFlags sampleCounts = getSampleCounts();
 
 	static const VkPhysicalDeviceLimits limits = {
-		1 << (vk::MAX_IMAGE_LEVELS_1D - 1),               // maxImageDimension1D
-		1 << (vk::MAX_IMAGE_LEVELS_2D - 1),               // maxImageDimension2D
-		1 << (vk::MAX_IMAGE_LEVELS_3D - 1),               // maxImageDimension3D
-		1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1),             // maxImageDimensionCube
-		vk::MAX_IMAGE_ARRAY_LAYERS,                       // maxImageArrayLayers
-		65536,                                            // maxTexelBufferElements
-		16384,                                            // maxUniformBufferRange
-		(1ul << 27),                                      // maxStorageBufferRange
-		vk::MAX_PUSH_CONSTANT_SIZE,                       // maxPushConstantsSize
-		4096,                                             // maxMemoryAllocationCount
-		vk::MAX_SAMPLER_ALLOCATION_COUNT,                 // maxSamplerAllocationCount
-		131072,                                           // bufferImageGranularity
-		0,                                                // sparseAddressSpaceSize (unsupported)
-		MAX_BOUND_DESCRIPTOR_SETS,                        // maxBoundDescriptorSets
-		16,                                               // maxPerStageDescriptorSamplers
-		14,                                               // maxPerStageDescriptorUniformBuffers
-		16,                                               // maxPerStageDescriptorStorageBuffers
-		16,                                               // maxPerStageDescriptorSampledImages
-		4,                                                // maxPerStageDescriptorStorageImages
-		sw::RENDERTARGETS,                                // maxPerStageDescriptorInputAttachments
-		128,                                              // maxPerStageResources
-		96,                                               // maxDescriptorSetSamplers
-		72,                                               // maxDescriptorSetUniformBuffers
-		MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC,       // maxDescriptorSetUniformBuffersDynamic
-		24,                                               // maxDescriptorSetStorageBuffers
-		MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC,       // maxDescriptorSetStorageBuffersDynamic
-		96,                                               // maxDescriptorSetSampledImages
-		24,                                               // maxDescriptorSetStorageImages
-		sw::RENDERTARGETS,                                // maxDescriptorSetInputAttachments
-		16,                                               // maxVertexInputAttributes
-		vk::MAX_VERTEX_INPUT_BINDINGS,                    // maxVertexInputBindings
-		2047,                                             // maxVertexInputAttributeOffset
-		2048,                                             // maxVertexInputBindingStride
-		sw::MAX_INTERFACE_COMPONENTS,                     // maxVertexOutputComponents
-		0,                                                // maxTessellationGenerationLevel (unsupported)
-		0,                                                // maxTessellationPatchSize (unsupported)
-		0,                                                // maxTessellationControlPerVertexInputComponents (unsupported)
-		0,                                                // maxTessellationControlPerVertexOutputComponents (unsupported)
-		0,                                                // maxTessellationControlPerPatchOutputComponents (unsupported)
-		0,                                                // maxTessellationControlTotalOutputComponents (unsupported)
-		0,                                                // maxTessellationEvaluationInputComponents (unsupported)
-		0,                                                // maxTessellationEvaluationOutputComponents (unsupported)
-		0,                                                // maxGeometryShaderInvocations (unsupported)
-		0,                                                // maxGeometryInputComponents (unsupported)
-		0,                                                // maxGeometryOutputComponents (unsupported)
-		0,                                                // maxGeometryOutputVertices (unsupported)
-		0,                                                // maxGeometryTotalOutputComponents (unsupported)
-		sw::MAX_INTERFACE_COMPONENTS,                     // maxFragmentInputComponents
-		sw::RENDERTARGETS,                                // maxFragmentOutputAttachments
-		1,                                                // maxFragmentDualSrcAttachments
-		28,                                               // maxFragmentCombinedOutputResources
-		32768,                                            // maxComputeSharedMemorySize
-		{ 65535, 65535, 65535 },                          // maxComputeWorkGroupCount[3]
-		256,                                              // maxComputeWorkGroupInvocations
-		{ 256, 256, 64 },                                 // maxComputeWorkGroupSize[3]
-		vk::SUBPIXEL_PRECISION_BITS,                      // subPixelPrecisionBits
-		4,                                                // subTexelPrecisionBits
-		4,                                                // mipmapPrecisionBits
-		UINT32_MAX,                                       // maxDrawIndexedIndexValue
-		UINT32_MAX,                                       // maxDrawIndirectCount
-		vk::MAX_SAMPLER_LOD_BIAS,                         // maxSamplerLodBias
-		16,                                               // maxSamplerAnisotropy
-		16,                                               // maxViewports
+		1 << (vk::MAX_IMAGE_LEVELS_1D - 1),          // maxImageDimension1D
+		1 << (vk::MAX_IMAGE_LEVELS_2D - 1),          // maxImageDimension2D
+		1 << (vk::MAX_IMAGE_LEVELS_3D - 1),          // maxImageDimension3D
+		1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1),        // maxImageDimensionCube
+		vk::MAX_IMAGE_ARRAY_LAYERS,                  // maxImageArrayLayers
+		65536,                                       // maxTexelBufferElements
+		16384,                                       // maxUniformBufferRange
+		(1ul << 27),                                 // maxStorageBufferRange
+		vk::MAX_PUSH_CONSTANT_SIZE,                  // maxPushConstantsSize
+		4096,                                        // maxMemoryAllocationCount
+		vk::MAX_SAMPLER_ALLOCATION_COUNT,            // maxSamplerAllocationCount
+		131072,                                      // bufferImageGranularity
+		0,                                           // sparseAddressSpaceSize (unsupported)
+		MAX_BOUND_DESCRIPTOR_SETS,                   // maxBoundDescriptorSets
+		16,                                          // maxPerStageDescriptorSamplers
+		14,                                          // maxPerStageDescriptorUniformBuffers
+		16,                                          // maxPerStageDescriptorStorageBuffers
+		16,                                          // maxPerStageDescriptorSampledImages
+		4,                                           // maxPerStageDescriptorStorageImages
+		sw::MAX_COLOR_BUFFERS,                       // maxPerStageDescriptorInputAttachments
+		128,                                         // maxPerStageResources
+		96,                                          // maxDescriptorSetSamplers
+		72,                                          // maxDescriptorSetUniformBuffers
+		MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC,  // maxDescriptorSetUniformBuffersDynamic
+		24,                                          // maxDescriptorSetStorageBuffers
+		MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC,  // maxDescriptorSetStorageBuffersDynamic
+		96,                                          // maxDescriptorSetSampledImages
+		24,                                          // maxDescriptorSetStorageImages
+		sw::MAX_COLOR_BUFFERS,                       // maxDescriptorSetInputAttachments
+		16,                                          // maxVertexInputAttributes
+		vk::MAX_VERTEX_INPUT_BINDINGS,               // maxVertexInputBindings
+		2047,                                        // maxVertexInputAttributeOffset
+		2048,                                        // maxVertexInputBindingStride
+		sw::MAX_INTERFACE_COMPONENTS,                // maxVertexOutputComponents
+		0,                                           // maxTessellationGenerationLevel (unsupported)
+		0,                                           // maxTessellationPatchSize (unsupported)
+		0,                                           // maxTessellationControlPerVertexInputComponents (unsupported)
+		0,                                           // maxTessellationControlPerVertexOutputComponents (unsupported)
+		0,                                           // maxTessellationControlPerPatchOutputComponents (unsupported)
+		0,                                           // maxTessellationControlTotalOutputComponents (unsupported)
+		0,                                           // maxTessellationEvaluationInputComponents (unsupported)
+		0,                                           // maxTessellationEvaluationOutputComponents (unsupported)
+		0,                                           // maxGeometryShaderInvocations (unsupported)
+		0,                                           // maxGeometryInputComponents (unsupported)
+		0,                                           // maxGeometryOutputComponents (unsupported)
+		0,                                           // maxGeometryOutputVertices (unsupported)
+		0,                                           // maxGeometryTotalOutputComponents (unsupported)
+		sw::MAX_INTERFACE_COMPONENTS,                // maxFragmentInputComponents
+		sw::MAX_COLOR_BUFFERS,                       // maxFragmentOutputAttachments
+		1,                                           // maxFragmentDualSrcAttachments
+		28,                                          // maxFragmentCombinedOutputResources
+		32768,                                       // maxComputeSharedMemorySize
+		{ 65535, 65535, 65535 },                     // maxComputeWorkGroupCount[3]
+		256,                                         // maxComputeWorkGroupInvocations
+		{ 256, 256, 64 },                            // maxComputeWorkGroupSize[3]
+		vk::SUBPIXEL_PRECISION_BITS,                 // subPixelPrecisionBits
+		4,                                           // subTexelPrecisionBits
+		4,                                           // mipmapPrecisionBits
+		UINT32_MAX,                                  // maxDrawIndexedIndexValue
+		UINT32_MAX,                                  // maxDrawIndirectCount
+		vk::MAX_SAMPLER_LOD_BIAS,                    // maxSamplerLodBias
+		16,                                          // maxSamplerAnisotropy
+		16,                                          // maxViewports
 		{ sw::MAX_VIEWPORT_DIM,
-		  sw::MAX_VIEWPORT_DIM },                         // maxViewportDimensions[2]
+		  sw::MAX_VIEWPORT_DIM },  // maxViewportDimensions[2]
 		{ -2 * sw::MAX_VIEWPORT_DIM,
-		   2 * sw::MAX_VIEWPORT_DIM - 1 },                // viewportBoundsRange[2]
+		  2 * sw::MAX_VIEWPORT_DIM - 1 },                 // viewportBoundsRange[2]
 		0,                                                // viewportSubPixelBits
 		64,                                               // minMemoryMapAlignment
 		vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT,            // minTexelBufferOffsetAlignment
@@ -527,7 +527,7 @@
 		sampleCounts,                                     // framebufferDepthSampleCounts
 		sampleCounts,                                     // framebufferStencilSampleCounts
 		sampleCounts,                                     // framebufferNoAttachmentsSampleCounts
-		sw::RENDERTARGETS,                                // maxColorAttachments
+		sw::MAX_COLOR_BUFFERS,                            // maxColorAttachments
 		sampleCounts,                                     // sampledImageColorSampleCounts
 		sampleCounts,                                     // sampledImageIntegerSampleCounts
 		sampleCounts,                                     // sampledImageDepthSampleCounts