From d6a37a0f151e390808f196998c48a341bc4c7b60 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 12 Mar 2021 11:58:14 -0800 Subject: Add a CPU renderer implementation (#1750) * Add a CPU renderer implementation This change adds a CPU back-end to `gfx` and ensures that most of our existing CPU tests pass when using it. Detailed notes: * Most of the CPU renderer implementation is copy-pasted from the CUDA case, so they share a lot of similar logic * The main addition to the CPU renderer is a semi-complete implementation of host-memory textures. The logic here handles all the main shapes (Buffer, 1D, 2D, 3D, Cube) and all the currently-supported `Format`s that are sample-able as-is (no D24S8). The implementation is not intended to be fast, and it currently only does nearest-neighbor sampling, but otherwise it tries to avoid cutting too many corners and should be ar reasonable starting point for a more complete (but not performance-oriented) implementation. * Refactored the CPU prelude `IRWTexture` interface to inherit from `ITexture`, since in most cases a single type will end up implementing both. It might be worth it to collapse it all down to a single interface later. * Changed the CPU prelude `ITexture`/`IRWTexture` interface so that it takes both a pointer *and* a size for output arguments. This change seems necessary to allow a shader variable declared as a `Texture2D` to fetch a single `float` when the underlying texture might be using RGBA32F. * Added to the `IComponentType` public API so that we can query a "host callable" for an entry point and not just a binary. * Turned off the `-shaderobj` flag on two tests that weren't yet compatible with shader objects but still had the flag left in on the path (since previously the CPU path always used the non-`gfx` non-shader-object logic anyway) * Disabled one test (`dynamic-dispatch-11`) that relied on the `ConstantBuffer` idiom that we know we are planning to chagne soon anyway. * Made a few changes to the CUDA path to bring it into line with what I added for the CPU path. These were mostly bug fixes around indexing logic for sub-objects and resources. * fixup --- tests/compute/dynamic-dispatch-11.slang | 6 +++++- tests/compute/performance-profile.slang | 2 +- tests/compute/unbounded-array-of-array-syntax.slang | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/compute/dynamic-dispatch-11.slang b/tests/compute/dynamic-dispatch-11.slang index 964431aaf..d6f64aa99 100644 --- a/tests/compute/dynamic-dispatch-11.slang +++ b/tests/compute/dynamic-dispatch-11.slang @@ -1,8 +1,12 @@ // Test using interface typed shader parameters with dynamic dispatch. +// TODO: This test has been disabled because it relies on +// `ConstantBuffer` which we expect to change +// implementation approaches for soon. + //DISABLE_TEST(compute):COMPARE_COMPUTE:-dx11 -shaderobj //DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -shaderobj -//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -disable-specialization -shaderobj +//DISABLE_TEST(compute):COMPARE_COMPUTE:-cpu -xslang -disable-specialization -shaderobj //DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -disable-specialization -shaderobj [anyValueSize(8)] diff --git a/tests/compute/performance-profile.slang b/tests/compute/performance-profile.slang index d8b9e31ae..24b0d04bd 100644 --- a/tests/compute/performance-profile.slang +++ b/tests/compute/performance-profile.slang @@ -1,5 +1,5 @@ //TEST(compute):PERFORMANCE_PROFILE:-cpu -compute -compile-arg -O3 -compute-dispatch 256,1,1 -shaderobj -//TEST(compute):PERFORMANCE_PROFILE:-cpu -compute -source-language cpp -compile-arg -O3 -compute-dispatch 256,1,1 -shaderobj +//TEST(compute):PERFORMANCE_PROFILE:-cpu -compute -source-language cpp -compile-arg -O3 -compute-dispatch 256,1,1 //TEST(compute):PERFORMANCE_PROFILE:-slang -compute -compute-dispatch 256,1,1 -shaderobj //TEST(compute):PERFORMANCE_PROFILE:-slang -compute -dx12 -compute-dispatch 256,1,1 -shaderobj //TEST(compute, vulkan):PERFORMANCE_PROFILE:-vk -compute -compute-dispatch 256,1,1 -shaderobj diff --git a/tests/compute/unbounded-array-of-array-syntax.slang b/tests/compute/unbounded-array-of-array-syntax.slang index 6a5f4ea6e..08ed17106 100644 --- a/tests/compute/unbounded-array-of-array-syntax.slang +++ b/tests/compute/unbounded-array-of-array-syntax.slang @@ -1,5 +1,5 @@ //IGNORE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp -//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute //TEST:CROSS_COMPILE:-target dxbc-assembly -entry computeMain -profile cs_5_1 //TEST:CROSS_COMPILE:-target spirv-assembly -entry computeMain -profile cs_5_1 //TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -- cgit v1.2.3