{
using namespace renderpass;
+typedef vector<deUint8> DepthValuesArray;
+
+static const deUint8 DEPTH_VALUES[] = { 0u, 255u, 1u };
+
enum AllocationKind
{
ALLOCATION_KIND_SUBALLOCATED,
, renderPassType (renderPassType_)
, requiredFeatures (requiredFeatures_)
{
+ DepthValuesArray shuffledDepthValues (&DEPTH_VALUES[0], &DEPTH_VALUES[DE_LENGTH_OF_ARRAY(DEPTH_VALUES)]);
+ de::Random rng (seed + 1);
+
+ rng.shuffle(shuffledDepthValues.begin(), shuffledDepthValues.end());
+
+ depthValues.push_back(shuffledDepthValues[0]);
+ depthValues.push_back(shuffledDepthValues[1]);
}
RenderPass renderPass;
AllocationKind allocationKind;
RenderPassType renderPassType;
vector<DeviceCoreFeature> requiredFeatures;
+ DepthValuesArray depthValues;
};
TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
}
-VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount)
+VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount, const DepthValuesArray& depthValues)
{
const float clearNan = tcu::Float32::nan().asFloat();
const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
: 0x0u;
if (tcu::hasDepthComponent(format.order))
- clearValue.depthStencil.depth = rng.getBool()
- ? 1.0f
- : 0.0f;
+ clearValue.depthStencil.depth = float(depthValues[rng.getBool() ? 1 : 0]) / 255.0f;
return clearValue;
}
}
PixelValue clearValueToPixelValue (const VkClearValue& value,
- const tcu::TextureFormat& format)
+ const tcu::TextureFormat& format,
+ const DepthValuesArray& depthValues)
{
const bool isDepthAttachment = hasDepthComponent(format.order);
const bool isStencilAttachment = hasStencilComponent(format.order);
{
if (isDepthAttachment)
{
- if (value.depthStencil.depth == 1.0f)
+ if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
pixelValue.setValue(0, true);
- else if (value.depthStencil.depth == 0.0f)
+ else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
pixelValue.setValue(0, false);
else
DE_FATAL("Unknown depth value");
const vector<SubpassRenderInfo>& subpassRenderInfo,
const UVec2& renderPos,
const UVec2& renderSize,
- const deUint32 drawStartNdx)
+ const deUint32 drawStartNdx,
+ const DepthValuesArray& depthValues)
{
const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
reference.resize(targetSize.x() * targetSize.y());
if (imageClearValues[attachmentNdx])
- clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format));
+ clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
}
for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
DE_ASSERT(!tcu::hasStencilComponent(format.order));
if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
- clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
+ clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
if (tcu::hasDepthComponent(format.order))
{
if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
- clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
+ clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
}
if (tcu::hasStencilComponent(format.order))
{
if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
- clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
+ clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
}
value.color = colorClear.getColor();
- clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format));
+ clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
}
if (renderInfo.getDepthStencilClear())
value.depthStencil.depth = dsClear.getDepth();
value.depthStencil.stencil = dsClear.getStencil();
- clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format));
+ clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
}
if (renderInfo.getRenderQuad())
void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
const vector<vector<PixelValue> >& referenceValues,
const UVec2& targetSize,
- const RenderPass& renderPassInfo)
+ const RenderPass& renderPassInfo,
+ const DepthValuesArray& depthValues)
{
referenceImages.resize(referenceValues.size());
if (reference[x + y * targetSize.x()].getValue(0))
{
if (*reference[x + y * targetSize.x()].getValue(0))
- depthAccess.setPixDepth(1.0f, x, y);
+ depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
else
- depthAccess.setPixDepth(0.0f, x, y);
+ depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
}
else // Fill with 3x3 grid
depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
bool verifyDepthAttachment (const vector<PixelValue>& reference,
const ConstPixelBufferAccess& result,
- const PixelBufferAccess& errorImage)
+ const PixelBufferAccess& errorImage,
+ const DepthValuesArray& depthValues)
{
const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
{
const bool value = *maybeValue;
- if ((value && (resultDepth != 1.0f))
- || (!value && resultDepth != 0.0f))
+ if ((value && (resultDepth != float(depthValues[1]) / 255.0f))
+ || (!value && resultDepth != float(depthValues[0]) / 255.0f))
pixelOk = false;
}
log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
- renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx);
- renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo);
+ renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
+ renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
{
log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
- && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess()))
+ && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues))
{
log << TestLog::Image("DepthAttachmentError" + de::toString(attachmentNdx), "Depth Attachment Error " + de::toString(attachmentNdx), depthErrorImage.getAccess());
isOk = false;
log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
- && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
+ && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues))
{
log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
isOk = false;
fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
<< ") " << boolOpToString(op) << " ("
<< "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
- << ") ? 1.0 : 0.0);\n";
+ << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
}
}
else
{
if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
{
- fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_depth" << attachmentNdx << ").x);\n";
+ fragmentShader << "\tinputs[" << inputValueNdx << "] = " << deUint32(config.depthValues[1]) << ".0f/255.0f == float(subpassLoad(i_depth" << attachmentNdx << ").x);\n";
inputValueNdx++;
}
for (size_t i = 0; i < inputsPerOutput; i++)
fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
- fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? 1.0 : 0.0;";
+ fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
}
}
}
}
}
-void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount)
+void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
{
for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
{
if (!isLazy[attachmentNdx])
- clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount)));
+ clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
else
clearValues.push_back(nothing<VkClearValue>());
}
}
-void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount)
+void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
{
for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
{
if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
|| attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
{
- clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount)));
+ clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
}
else
clearValues.push_back(nothing<VkClearValue>());
const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
- const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount);
+ const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
}
}
initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
- initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount);
+ initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
- initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount);
+ initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);