<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tools/gfx/render-graphics-common.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2021-03-24T20:57:55+00:00</updated>
<entry>
<title>Reimplement Vulkan shader objects. (#1764)</title>
<updated>2021-03-24T20:57:55+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2021-03-24T20:57:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=98afb421f408aa8651afff3dba1b21fad71131fe'/>
<id>urn:sha1:98afb421f408aa8651afff3dba1b21fad71131fe</id>
<content type='text'>
* Reimplement Vulkan shader objects.

This change reimplements Vulkan shader objects in the `gfx` layer so that it is no longer layered on top of the `DescriptorSet` abstraction. Since this is the last implementation that uses `DescriptorSet`, the change also removes all `DescriptorSet` related API from public `gfx` interface.

The Vulkan implementation now passes all test cases, but it still have two issues:
1. The PushConstant setting is not correct, this is because we don't seem to be able to get correct reflection data about the size of push constants for an entry-point.
2. The `shader-toy` example can't run on Vulkan, because it currently sets nullptr to `Texture` bindings, and this change doesn't properly handle setting resource to null in `ShaderObject`s yet. If we can use the `nullDescriptor` feature on vulkan, this implementation will be simple. However we still want to decide whether we want to use a Vulkan 1.2 feature for this.

* Fix up</content>
</entry>
<entry>
<title>Remove `DescriptorSet` from D3D11 and GL devices. (#1761)</title>
<updated>2021-03-18T20:19:58+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2021-03-18T20:19:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0f9b3a95a6cc087bc1e34d4becff04fa6160c582'/>
<id>urn:sha1:0f9b3a95a6cc087bc1e34d4becff04fa6160c582</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add a CPU renderer implementation (#1750)</title>
<updated>2021-03-12T19:58:14+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-03-12T19:58:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d6a37a0f151e390808f196998c48a341bc4c7b60'/>
<id>urn:sha1:d6a37a0f151e390808f196998c48a341bc4c7b60</id>
<content type='text'>
* 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&lt;float&gt;` 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&lt;IInterface&gt;` 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</content>
</entry>
<entry>
<title>Swapchain resize and rename to `IDevice` (#1741)</title>
<updated>2021-03-10T18:58:15+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2021-03-10T18:58:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=6ef4054f8a8aea4ec61481057fa7e16aaecde6d7'/>
<id>urn:sha1:6ef4054f8a8aea4ec61481057fa7e16aaecde6d7</id>
<content type='text'>
* Swapchain resize

* Fix.</content>
</entry>
<entry>
<title>Refactor `gfx` to surface `CommandBuffer` interface. (#1735)</title>
<updated>2021-03-05T00:25:58+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2021-03-05T00:25:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=a5ac4999b4dea546a7ef824669ab1809224b6448'/>
<id>urn:sha1:a5ac4999b4dea546a7ef824669ab1809224b6448</id>
<content type='text'>
* Refactor `gfx` to surface `CommandBuffer` interface.

* Fixes.

* Fix code review issues, and make vulkan runnable on devices without VK_EXT_extended_dynamic_states.

* Update solution files

* Move out-of-date examples to examples/experimental

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Shader object specialization work-in-progress (#1728)</title>
<updated>2021-02-26T17:43:03+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-02-26T17:43:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b3501add6c4dda798acf7b84b71b638d8d0b7898'/>
<id>urn:sha1:b3501add6c4dda798acf7b84b71b638d8d0b7898</id>
<content type='text'>
* Shader object specialization work-in-progress

The big change here is in the `setObject()` implementations, where we now take write the witness table ID and data for the value being assigned in both the CUDA and graphics-API paths (it is possible the code could be shared...). The logic for deciding whether a value "fits" in the existential value payload should actually be correct here, since it uses the reflection data.

The other relevant change is that the logic for writing out the ordinary/uniform data for a shader object on the graphics-API path has been updated so that it only allocates the GPU buffer *after* it knows the specialized layout, and can thus allocate space for any extra parameter data that wasn't in the original layout but got added by specialization. There is some inactive code in place that tries to sketch how the implementation should handle writing the data of sub-objects for interface-type fields into the appropriate areas of the allocated buffer for a parent object, but that is stubbed out for now pending implementation of the relevant reflection information.

This change also introduces logic in the graphics-API path to create a specialized layout for a shader object on-demand (so that it will only be created after the specialization arguments are known or can be inferred). The implementation needs to treat ordinary shader objects and root shader objects differently because the Slang API handles specialization differently for ordinary types vs. `IComponentType`s.

Some notes and caveats:

* The CUDA path doesn't need to compute specialized layouts the way the graphics-API path does because layout doesn't change based on specialization for that path (just as it won't for the CPU path)

* This code just skips over the RTTI field in existential values because it seems that we currently aren't using it in generated code.

* We are completely missing the logic for recursively writing the resource ranges of sub-objects bound to interface-type fields into the descriptor set(s) of the parent object. The missing link there is reflection API support, just as it is for filling in the ordinary/uniform data. We need a way to get the binding range offset (and binding array stride) for the "pending" data of a specialized interface-type field.

* The logic for computing specialization arguments based on the shader objects bound to interface-type fields has a lot of holes. Some of the indexing math is flat-out incorrect, and it also doesn't make any attempt to handle sub-object ranges with more than one element in them. I tweaked some of the code there to make it *more* correct, but that doesn't mean it is actually correct at this point.

* The logic for computing a specialized `IComponentType` for a `ProgramVars` in the graphics-API path seems to have a lot of overlap with `maybeSpecializeProgram()`, so we should look into ways to avoid the duplication over time.

* clang error fix</content>
</entry>
<entry>
<title>Explicit swapchain interface in `gfx`. (#1726)</title>
<updated>2021-02-24T23:43:43+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2021-02-24T23:43:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9b7a007c31072bc9aebd1134aa4f1bfd28a4c541'/>
<id>urn:sha1:9b7a007c31072bc9aebd1134aa4f1bfd28a4c541</id>
<content type='text'>
* Explicit swapchain interface in `gfx`.

* Correctly return nullptr when `IRenderer` creation failed.

* Fix crashes on CUDA tests.

* Cleanups.</content>
</entry>
<entry>
<title>Streamline shader object creation (#1717)</title>
<updated>2021-02-18T02:42:23+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-02-18T02:42:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b1e376fa1e7dd0ff59991bdf1d3d859d3b63a74a'/>
<id>urn:sha1:b1e376fa1e7dd0ff59991bdf1d3d859d3b63a74a</id>
<content type='text'>
This change kind of rolls together two different simplifications:

1. The `createShaderObject()` shouldn't really need to take an `IShaderObjectLayout` because it could just take the `slang::TypeLayoutReflection` instead and create the shader-object layout behind the scenes.

2. For that matter, it needn't take a `slang::TypeLayoutReflection` either, becaues it could just take a `slang::TypeReflection` and query the layout of that type behind the scenes.

The combination of these two changes means:

* `IShaderObjectLayout` is gone from the public API, as is `createShaderObjectLayout()`

* `createShaderObject()` directly takes a `slang::TypeReflection` and allocates a shader object of that type

The result is simpler and more streamlined application code.

Note that under the hood the implementation still has shader-object layouts, using the `ShaderObjectLayoutBase` class. A few locations had to change to use `RefPtr`s instead of `ComPtr`s now that the class is no longer a public COM-lite API type.

The hope is that this change makes it easier to allocate/cache layouts for things like specialized types "under the hood," as is needed to implement parameter setting for static specialization.</content>
</entry>
<entry>
<title>Use CPU memory for shader object ordinary data (#1714)</title>
<updated>2021-02-18T00:53:17+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-02-18T00:53:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=62a0193dff6986d2ce96867702c3d31371652cc9'/>
<id>urn:sha1:62a0193dff6986d2ce96867702c3d31371652cc9</id>
<content type='text'>
This change makes it so that the shared shader object implementation across graphics APIs (everything except CUDA and CPU) uses a host-memory buffer to store ordinary (aka "uniform") data while the shader object is being set up / modified, and then allocates and initializes a GPU-memory buffer for the data on-demand once setup is complete.

This choice is a necessary step for supporting interface/existential-type fields in the presence of static specialization, because any fixed-size GPU buffer we would try to allocate at the time an object is first created might not turn out to be large enough if static specialization must handle a concrete type that doesn't "fit" into the fixed-size space reserved for an existential value (resulting in the value having to be placed in an overflow region outside the original object).

This change does *not* include any of the work related to actually laying out existential-type fields in this fashion. It instead just focuses on changing when and where the GPU memory allocation is performed to one that is more appropriate for those subsequent changes.</content>
</entry>
<entry>
<title>Fixes to get shader-object example working on CUDA (#1708)</title>
<updated>2021-02-16T22:03:39+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-02-16T22:03:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=39975b207e5db7de8feaaebfda2ae122c1850b26'/>
<id>urn:sha1:39975b207e5db7de8feaaebfda2ae122c1850b26</id>
<content type='text'>
The purpose of these changes is to make the `shader-object` example work correctly on CUDA.

Originally I had tried to add changes to the "flat" reflection information so that it introduced descriptor ranges to match the binding ranges it added for interface/existential-type fields. This approach helped the CUDA code that was using that information to try and compute uniform offsets for those fields, but it broke most of the other renderer back-ends. Instead, I removed the relevant asserts from `CUDAShaderObject::setObject()`.

Note taht there are leftover changes from my edits to the flat reflection information, around how it handles "leaf" fields that consume multiple resource kinds. I believe that those changes are, on balance, "more correct" now than they were before, so I decided to leave them in.

The other major fix here is to specialize the `CUDAShaderObject::setObject()` logic to handle the case of setting a shader object for a parameter that has interface type instead of a constant-buffer or parameter block. Mostly I just copy bytes from the child object into the parent object. There are a few caveats, though:

* I am not writing the RTTI or witness-table information, so dynamic dispatch won't work.

* I am assuming a hard-coded offset of 16 bytes for the any-value, which will work for now but is a bit too "magical" and might also break once we support conjunctions of interfaces with dynamic dispatch

* I am assuming that the child value to be writen into the field will "fit" into the any-value area. We need some way to determine whether or not things fit dynamically (ideally using the reflection data), and adapt accordingly.

* I had to add another method on the base CUDA shader object type to handle setting data using a device-memory pointr instead of a host-memory pointer

* There's not a lot we can do about it, but in the case of assigning an ordinary `CUDAShaderObject` into an interface-type field of a `CUDAEntryPointShaderObject` we end up needing to perform a device-&gt;host memory copy, because the bytes of the value will have already been written to GPU memory, but need to be in GPU memory for the dispatch call.

* The implementation I'm using here basically assumes that the child shader object must have been finalized before it gets plugged into the parent shader object. We haven't yet made a policy decision about that bit.</content>
</entry>
</feed>
