From 71885de27c973a73b7d020f5ebbe86e16b86d7e4 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 18 Mar 2019 18:19:26 -0400 Subject: First pass support for half on vk (#912) * Look at getting half to work on vk. * Alter half test so can always produce consistent test results. * First pass working half on vk. * Improve comments for vulkan extensions around half. * Upgraded vulkan headers to v1.1.103 https://github.com/KhronosGroup/Vulkan-Headers * * Add getFeatures on Render interface * Vulkan renderer determines at startup if it can support half * Parse render-features on render-test * Small changes to half-calc.slang test. * Structured buffer half access works as expected for Vk, but isn't for dx12, so disable for now. * Require the half feature for renderers for the half-structured-buffer.slang test. * * Added ToolReturnCode to be more rigerous about how a return code is passed back from a tool * Added support for a tool being able to pass back an 'ignored' result. * Used enum codes to indicate meanings * Made spawnAndWait return a ToolReturnCode * Ignore tests that don't have required render-feature * Fix macro line continuation usage. * Check dx12 has half support. * Checking for half on dx12 - if CheckFeatureSupport fails, don't fail renderer initialization. * Fix typo. --- tests/compute/half-calc.slang | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/compute/half-calc.slang (limited to 'tests/compute/half-calc.slang') diff --git a/tests/compute/half-calc.slang b/tests/compute/half-calc.slang new file mode 100644 index 000000000..b47678dae --- /dev/null +++ b/tests/compute/half-calc.slang @@ -0,0 +1,32 @@ +//TEST(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half +//TEST(compute):COMPARE_COMPUTE:-vk -compute -use-dxil -profile cs_6_2 -render-features half +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +// Test for doing a calculation using half + +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + //half2 v0 = { 1, -2 }; + //half2 v1 = { -2, 4 }; + + //half2 v2 = (v0 * 2.0f + v1); + + // This should work (it compiles on dxc, but slang doesn't seem to have overloads yet) + //half offset = length(v2); + + //half offset = v2.x + v2.y; + + half offset = 0.0f; + + half v = tid; + v *= half(3.0f); + v += half(1.0f); + v += offset; + + outputBuffer[tid] = v; +} \ No newline at end of file -- cgit v1.2.3