typedef de::SharedPtr<ModuleHandleUp> ModuleHandleSp;
typedef std::pair<std::string, vk::VkShaderStageFlagBits> EntryToStage;
typedef std::map<std::string, std::vector<EntryToStage> > ModuleMap;
-typedef std::map<vk::VkShaderStageFlagBits, std::vector<deInt32> > StageToSpecConstantMap;
-typedef std::pair<vk::VkDescriptorType, BufferSp> Resource;
+typedef std::map<vk::VkShaderStageFlagBits, SpecConstants > StageToSpecConstantMap;
enum NumberType
{
NUMBERTYPE_INT16,
NUMBERTYPE_UINT16,
NUMBERTYPE_FLOAT16,
+ NUMBERTYPE_END16, // Marks the end of 16-bit scalar types
+ NUMBERTYPE_FLOAT64,
};
typedef enum RoundingModeFlags_e
ROUNDINGMODE_RTZ = 0x2, // Round to zero
} RoundingModeFlags;
-typedef bool (*GraphicsVerifyIOFunc) (const std::vector<Resource>& inputs,
- const std::vector<AllocationSp>& outputAllocations,
- const std::vector<Resource>& expectedOutputs,
- tcu::TestLog& log);
-
typedef bool (*GraphicsVerifyBinaryFunc) (const ProgramBinary& binary);
// Resources used by graphics-pipeline-based tests.
{
// Resources used as inputs.
std::vector<Resource> inputs;
+ // Input resource format if used
+ VkFormat inputFormat;
// Resources used as outputs. The data supplied will be used as
// the expected outputs for the corresponding bindings by default.
// If other behaviors are needed, please provide a custom verifyIO.
// be called. If true is returned, then the test case is assumed to
// have passed, if false is returned, then the test case is assumed
// to have failed.
- GraphicsVerifyIOFunc verifyIO;
+ VerifyIOFunc verifyIO;
GraphicsVerifyBinaryFunc verifyBinary;
SpirvVersion spirvVersion;
GraphicsResources()
- : verifyIO (DE_NULL)
+ : inputFormat (VK_FORMAT_R32G32B32A32_SFLOAT)
+ , verifyIO (DE_NULL)
, verifyBinary (DE_NULL)
, spirvVersion (SPIRV_VERSION_1_0)
{}
, elementType (elementT)
{
DE_ASSERT(numE > 0 && numE < 5);
- DE_ASSERT(elementT != NUMBERTYPE_END32);
+ DE_ASSERT(elementT != NUMBERTYPE_END32 && elementT != NUMBERTYPE_END16);
}
IFDataType (const IFDataType& that)
std::string str (void) const;
bool elementIs32bit (void) const { return elementType < NUMBERTYPE_END32; }
+ bool elementIs64bit (void) const { return elementType > NUMBERTYPE_END16; }
+
bool isVector (void) const { return numElements > 1; }
deUint32 numElements;
};
// Returns the corresponding buffer usage flag bit for the given descriptor type.
-VkBufferUsageFlagBits getMatchingBufferUsageFlagBit(VkDescriptorType dType);
+VkBufferUsageFlagBits getMatchingBufferUsageFlagBit (VkDescriptorType dType);
// Context for a specific test instantiation. For example, an instantiation
// may test colors yellow/magenta/cyan/mauve in a tesselation shader
bool hasTessellation;
vk::VkShaderStageFlagBits requiredStages;
std::vector<std::string> requiredDeviceExtensions;
- std::vector<std::string> requiredDeviceFeatures;
VulkanFeatures requestedFeatures;
PushConstants pushConstants;
// Specifies the (one or more) stages that use a customized shader code.
GraphicsInterfaces interfaces;
qpTestResult failResult;
std::string failMessageTemplate; //!< ${reason} in the template will be replaced with a detailed failure message
+ bool renderFullSquare; // Forces to render whole render area, though with background color
InstanceContext (const tcu::RGBA (&inputs)[4],
const tcu::RGBA (&outputs)[4],
const GraphicsResources& resources_,
const GraphicsInterfaces& interfaces_,
const std::vector<std::string>& extensions_,
- const std::vector<std::string>& features_,
VulkanFeatures vulkanFeatures_,
VkShaderStageFlags customizedStages_);
std::string getSpecializedFailMessage (const std::string& failureReason);
};
+enum ShaderTask
+{
+ SHADER_TASK_NONE = 0,
+ SHADER_TASK_NORMAL,
+ SHADER_TASK_UNUSED_VAR,
+ SHADER_TASK_UNUSED_FUNC,
+ SHADER_TASK_LAST
+};
+
+enum ShaderTaskIndex
+{
+ SHADER_TASK_INDEX_VERTEX = 0,
+ SHADER_TASK_INDEX_GEOMETRY = 1,
+ SHADER_TASK_INDEX_TESS_CONTROL = 2,
+ SHADER_TASK_INDEX_TESS_EVAL = 3,
+ SHADER_TASK_INDEX_FRAGMENT = 4,
+ SHADER_TASK_INDEX_LAST = 5
+};
+
+typedef ShaderTask ShaderTaskArray[SHADER_TASK_INDEX_LAST];
+
+struct UnusedVariableContext
+{
+ InstanceContext instanceContext;
+ ShaderTaskArray shaderTasks;
+ VariableLocation variableLocation;
+
+ UnusedVariableContext(const InstanceContext& ctx, const ShaderTaskArray& tasks, const VariableLocation& location)
+ : instanceContext(ctx), shaderTasks(), variableLocation(location)
+ {
+ deMemcpy(shaderTasks, tasks, sizeof(tasks));
+ }
+};
+
// A description of a shader to be used for a single stage of the graphics pipeline.
struct ShaderElement
{
return ss.str();
}
-// Performs a bitwise copy of source to the destination type Dest.
-template <typename Dest, typename Src>
-Dest bitwiseCast(Src source)
-{
- Dest dest;
- DE_STATIC_ASSERT(sizeof(source) == sizeof(dest));
- deMemcpy(&dest, &source, sizeof(dest));
- return dest;
-}
-
-template<typename T> T randomScalar (de::Random& rnd, T minValue, T maxValue);
-template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); }
-template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); }
-
-
void getDefaultColors (tcu::RGBA (&colors)[4]);
void getHalfColorsFullAlpha (tcu::RGBA (&colors)[4]);
void getInvertedDefaultColors (tcu::RGBA (&colors)[4]);
// Creates fragments that specialize into a simple pass-through shader (of any kind).
-std::map<std::string, std::string> passthruFragments(void);
+std::map<std::string, std::string> passthruFragments (void);
+
+// Creates a combined shader module based on VkShaderStageFlagBits defined in InstanceContext.
+void createCombinedModule (vk::SourceCollections& dst, InstanceContext ctx);
-void createCombinedModule(vk::SourceCollections& dst, InstanceContext);
+// Creates shaders with unused variables based on the UnusedVariableContext.
+void createUnusedVariableModules (vk::SourceCollections& dst, UnusedVariableContext ctx);
// This has two shaders of each stage. The first
// is a passthrough, the second inverts the color.
-void createMultipleEntries(vk::SourceCollections& dst, InstanceContext);
+void createMultipleEntries (vk::SourceCollections& dst, InstanceContext);
-// Turns a statically sized array of ShaderElements into an instance-context
-// by setting up the mapping of modules to their contained shaders and stages.
-// The inputs and expected outputs are given by inputColors and outputColors
-template<size_t N>
-InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
+// Turns a vector of ShaderElements into an instance-context by setting up the mapping of modules
+// to their contained shaders and stages. The inputs and expected outputs are given by inputColors
+// and outputColors
+InstanceContext createInstanceContext (const std::vector<ShaderElement>& elements,
const tcu::RGBA (&inputColors)[4],
const tcu::RGBA (&outputColors)[4],
const std::map<std::string, std::string>& testCodeFragments,
const GraphicsResources& resources,
const GraphicsInterfaces& interfaces,
const std::vector<std::string>& extensions,
- const std::vector<std::string>& features,
VulkanFeatures vulkanFeatures,
VkShaderStageFlags customizedStages,
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
- const std::string& failMessageTemplate = std::string())
+ const std::string& failMessageTemplate = std::string());
+
+// Same as above but using a statically sized array.
+template <size_t N>
+inline InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
+ const tcu::RGBA (&inputColors)[4],
+ const tcu::RGBA (&outputColors)[4],
+ const std::map<std::string, std::string>& testCodeFragments,
+ const StageToSpecConstantMap& specConstants,
+ const PushConstants& pushConstants,
+ const GraphicsResources& resources,
+ const GraphicsInterfaces& interfaces,
+ const std::vector<std::string>& extensions,
+ VulkanFeatures vulkanFeatures,
+ VkShaderStageFlags customizedStages,
+ const qpTestResult failResult = QP_TEST_RESULT_FAIL,
+ const std::string& failMessageTemplate = std::string())
{
- InstanceContext ctx (inputColors, outputColors, testCodeFragments, specConstants, pushConstants, resources, interfaces, extensions, features, vulkanFeatures, customizedStages);
- for (size_t i = 0; i < N; ++i)
- {
- ctx.moduleMap[elements[i].moduleName].push_back(std::make_pair(elements[i].entryName, elements[i].stage));
- ctx.requiredStages = static_cast<VkShaderStageFlagBits>(ctx.requiredStages | elements[i].stage);
- }
- ctx.failResult = failResult;
- if (!failMessageTemplate.empty())
- ctx.failMessageTemplate = failMessageTemplate;
- return ctx;
+ std::vector<ShaderElement> elementsVector(elements, elements + N);
+ return createInstanceContext(elementsVector, inputColors, outputColors, testCodeFragments, specConstants, pushConstants,
+ resources, interfaces, extensions, vulkanFeatures, customizedStages, failResult, failMessageTemplate);
}
// The same as createInstanceContext above, without extensions, spec constants, and resources.
-template<size_t N>
-inline InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
- tcu::RGBA (&inputColors)[4],
- const tcu::RGBA (&outputColors)[4],
- const std::map<std::string, std::string>& testCodeFragments)
+InstanceContext createInstanceContext (const std::vector<ShaderElement>& elements,
+ tcu::RGBA (&inputColors)[4],
+ const tcu::RGBA (&outputColors)[4],
+ const std::map<std::string, std::string>& testCodeFragments);
+
+// Same as above, but using a statically sized array.
+template <size_t N>
+inline InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
+ tcu::RGBA (&inputColors)[4],
+ const tcu::RGBA (&outputColors)[4],
+ const std::map<std::string, std::string>& testCodeFragments)
{
- return createInstanceContext(elements, inputColors, outputColors, testCodeFragments,
- StageToSpecConstantMap(), PushConstants(), GraphicsResources(),
- GraphicsInterfaces(), std::vector<std::string>(), std::vector<std::string>(),
- VulkanFeatures(), vk::VK_SHADER_STAGE_ALL);
+ std::vector<ShaderElement> elementsVector(elements, elements + N);
+ return createInstanceContext(elementsVector, inputColors, outputColors, testCodeFragments);
}
// The same as createInstanceContext above, but with default colors.
+InstanceContext createInstanceContext (const std::vector<ShaderElement>& elements,
+ const std::map<std::string, std::string>& testCodeFragments);
+
+// Same as above, but using a statically sized array.
template<size_t N>
-InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
- const std::map<std::string, std::string>& testCodeFragments)
+inline InstanceContext createInstanceContext (const ShaderElement (&elements)[N],
+ const std::map<std::string, std::string>& testCodeFragments)
{
- tcu::RGBA defaultColors[4];
- getDefaultColors(defaultColors);
- return createInstanceContext(elements, defaultColors, defaultColors, testCodeFragments);
+ std::vector<ShaderElement> elementsVector(elements, elements + N);
+ return createInstanceContext(elementsVector, testCodeFragments);
}
-void addShaderCodeCustomVertex(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
-void addShaderCodeCustomTessControl(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
-void addShaderCodeCustomTessEval(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
-void addShaderCodeCustomGeometry(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
-void addShaderCodeCustomFragment(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+// Create an unused variable context for the given combination.
+UnusedVariableContext createUnusedVariableContext(const ShaderTaskArray& shaderTasks, const VariableLocation& location);
+
+void addShaderCodeCustomVertex (vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+void addShaderCodeCustomTessControl (vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+void addShaderCodeCustomTessEval (vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+void addShaderCodeCustomGeometry (vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+void addShaderCodeCustomFragment (vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
+
+void createTestForStage (vk::VkShaderStageFlagBits stage,
+ const std::string& name,
+ const tcu::RGBA (&inputColors)[4],
+ const tcu::RGBA (&outputColors)[4],
+ const std::map<std::string, std::string>& testCodeFragments,
+ const SpecConstants& specConstants,
+ const PushConstants& pushConstants,
+ const GraphicsResources& resources,
+ const GraphicsInterfaces& interfaces,
+ const std::vector<std::string>& extensions,
+ VulkanFeatures vulkanFeatures,
+ tcu::TestCaseGroup* tests,
+ const qpTestResult failResult = QP_TEST_RESULT_FAIL,
+ const std::string& failMessageTemplate = std::string(),
+ const bool renderFullSquare = false);
void createTestsForAllStages (const std::string& name,
const tcu::RGBA (&inputColors)[4],
const tcu::RGBA (&outputColors)[4],
const std::map<std::string, std::string>& testCodeFragments,
- const std::vector<deInt32>& specConstants,
+ const SpecConstants& specConstants,
const PushConstants& pushConstants,
const GraphicsResources& resources,
const GraphicsInterfaces& interfaces,
const std::vector<std::string>& extensions,
- const std::vector<std::string>& features,
VulkanFeatures vulkanFeatures,
tcu::TestCaseGroup* tests,
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
const std::string& failMessageTemplate = std::string())
{
- std::vector<deInt32> noSpecConstants;
+ SpecConstants noSpecConstants;
PushConstants noPushConstants;
GraphicsResources noResources;
GraphicsInterfaces noInterfaces;
std::vector<std::string> noExtensions;
- std::vector<std::string> noFeatures;
createTestsForAllStages(
name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
- noResources, noInterfaces, noExtensions, noFeatures, VulkanFeatures(),
+ noResources, noInterfaces, noExtensions, VulkanFeatures(),
tests, failResult, failMessageTemplate);
}
const tcu::RGBA (&inputColors)[4],
const tcu::RGBA (&outputColors)[4],
const std::map<std::string, std::string>& testCodeFragments,
- const std::vector<deInt32>& specConstants,
+ const SpecConstants& specConstants,
tcu::TestCaseGroup* tests,
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
const std::string& failMessageTemplate = std::string())
GraphicsResources noResources;
GraphicsInterfaces noInterfaces;
std::vector<std::string> noExtensions;
- std::vector<std::string> noFeatures;
createTestsForAllStages(
name, inputColors, outputColors, testCodeFragments, specConstants, noPushConstants,
- noResources, noInterfaces, noExtensions, noFeatures, VulkanFeatures(),
+ noResources, noInterfaces, noExtensions, VulkanFeatures(),
tests, failResult, failMessageTemplate);
}
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
const std::string& failMessageTemplate = std::string())
{
- std::vector<deInt32> noSpecConstants;
+ SpecConstants noSpecConstants;
PushConstants noPushConstants;
GraphicsInterfaces noInterfaces;
- std::vector<std::string> noFeatures;
createTestsForAllStages(
name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
- resources, noInterfaces, extensions, noFeatures, vulkanFeatures,
+ resources, noInterfaces, extensions, vulkanFeatures,
tests, failResult, failMessageTemplate);
}
const std::string& failMessageTemplate = std::string())
{
GraphicsResources noResources;
- std::vector<deInt32> noSpecConstants;
- std::vector<std::string> noFeatures;
+ SpecConstants noSpecConstants;
PushConstants noPushConstants;
createTestsForAllStages(
name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
- noResources, interfaces, extensions, noFeatures, vulkanFeatures,
+ noResources, interfaces, extensions, vulkanFeatures,
tests, failResult, failMessageTemplate);
}
const qpTestResult failResult = QP_TEST_RESULT_FAIL,
const std::string& failMessageTemplate = std::string())
{
- std::vector<deInt32> noSpecConstants;
+ SpecConstants noSpecConstants;
GraphicsInterfaces noInterfaces;
- std::vector<std::string> noFeatures;
createTestsForAllStages(
name, inputColors, outputColors, testCodeFragments, noSpecConstants, pushConstants,
- resources, noInterfaces, extensions, noFeatures, vulkanFeatures,
+ resources, noInterfaces, extensions, vulkanFeatures,
tests, failResult, failMessageTemplate);
}
// whatever the shaders draw can be directly spot-checked.
tcu::TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instance);
+// Use the instance context in the UnusedVariableContext to run the function above.
+tcu::TestStatus runAndVerifyUnusedVariablePipeline (Context &context, UnusedVariableContext unusedVariableContext);
+
// Adds a new test to group using custom fragments for the tessellation-control
// stage and passthrough fragments for all other stages. Uses default colors
// for input and expected output.
-void addTessCtrlTest(tcu::TestCaseGroup* group, const char* name, const std::map<std::string, std::string>& fragments);
+void addTessCtrlTest (tcu::TestCaseGroup* group, const char* name, const std::map<std::string, std::string>& fragments);
// Given the original 32-bit float value, computes the corresponding 16-bit
// float value under the given rounding mode flags and compares with the
// * For the rest, require exactly the same bit pattern.
bool compare16BitFloat (float original, deUint16 returned, RoundingModeFlags flags, tcu::TestLog& log);
+// Given the original 16-bit float value, computes the corresponding 32-bit
+// float value and compares with the returned 32-bit float value.
+// Returns true if they are considered as equal.
+//
+// The following equivalence criteria are respected:
+// * Positive and negative zeros are considered equivalent.
+// * Denormalized floats are allowed to be flushed to zeros, including
+// * Inputted 16bit denormalized float
+// * Generated 32bit denormalized float
+// * Different bit patterns of NaNs are allowed.
+// * For the rest, require exactly the same bit pattern.
+bool compare16BitFloat (deUint16 returned, float original, tcu::TestLog& log);
+bool compare16BitFloat (deFloat16 original, deFloat16 returned, std::string& error);
+
+// Given the original 64-bit float value, computes the corresponding 16-bit
+// float value under the given rounding mode flags and compares with the
+// returned 16-bit float value. Returns true if they are considered as equal.
+//
+// The following equivalence criteria are respected:
+// * Positive and negative zeros are considered equivalent.
+// * Denormalized floats are allowed to be flushed to zeros, including
+// * Inputted 64bit denormalized float
+// * Generated 16bit denormalized float
+// * Different bit patterns of NaNs are allowed.
+// * For the rest, require exactly the same bit pattern.
+bool compare16BitFloat64 (double original, deUint16 returned, RoundingModeFlags flags, tcu::TestLog& log);
+
// Compare the returned 32-bit float against its expected value.
//
// The following equivalence criteria are respected:
// * For the rest, use C++ float equivalence check.
bool compare32BitFloat (float expected, float returned, tcu::TestLog& log);
+// Compare the returned 64-bit float against its expected value.
+//
+// The following equivalence criteria are respected:
+// * Denormalized floats are allowed to be flushed to zeros, including
+// * The expected value itself is a denormalized float
+// * The expected value is a denormalized float if converted to 16bit
+// * Different bit patterns of NaNs/Infs are allowed.
+// * For the rest, use C++ float equivalence check.
+bool compare64BitFloat (double expected, double returned, tcu::TestLog& log);
+
} // SpirVAssembly
} // vkt