Skip to content

Commit c6332c0

Browse files
committed
cut DXILResources.rst down to just the buffer parts
A lot of this document is in flux, but it would be helpful to get the parts we're already working on in tree. To facilitate that, cut out everything that isn't about handles or buffers.
1 parent 591b5c7 commit c6332c0

File tree

1 file changed

+0
-334
lines changed

1 file changed

+0
-334
lines changed

llvm/docs/DirectX/DXILResources.rst

Lines changed: 0 additions & 334 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,6 @@ parameterized. This is different than DXIL, as simplifying the types to
9191
something like "dx.srv" and "dx.uav" types would mean the operations on these
9292
types would have to be overly generic.
9393

94-
Samplers
95-
--------
96-
97-
.. code-block:: llvm
98-
99-
target("dx.Sampler", SamplerType)
100-
101-
The "dx.Sampler" type is used to represent sampler state. The sampler type is
102-
an enum value from the DXIL ABI, and these appear in sampling operations as
103-
well as LOD calculations and texture gather.
104-
105-
Constant Buffers
106-
----------------
107-
108-
.. code-block:: llvm
109-
110-
target("dx.CBuffer", BufferSize)
111-
112-
The "dx.CBuffer" type is a constant buffer of the given size. Note that despite
113-
the name this is distinct from the buffer types, and can only be read using the
114-
``llvm.dx.cbufferLoad`` operation.
115-
11694
Buffers
11795
-------
11896

@@ -156,55 +134,6 @@ There are a few fields to describe variants of all of these types:
156134
.. _rawBufferLoad: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#rawbufferload
157135
.. _rawBufferStore: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#rawbufferstore
158136

159-
Textures
160-
--------
161-
162-
.. code-block:: llvm
163-
164-
target("dx.Texture1D", ElementType, IsWriteable, IsROV)
165-
target("dx.Texture1DArray", ...)
166-
target("dx.Texture2D", ...)
167-
target("dx.Texture2DArray", ...)
168-
target("dx.Texture3D", ...)
169-
target("dx.TextureCUBE", ...)
170-
target("dx.TextureCUBEArray", ...)
171-
172-
target("dx.Texture2DMS", ElementType, IsWriteable, IsROV, SampleCount)
173-
target("dx.Texture2DMSArray", ...)
174-
175-
target("dx.FeedbackTexture2D", ElementType, IsWriteable, IsROV, FeedbackType)
176-
target("dx.FeedbackTexture2DArray", ...)
177-
178-
There are a number of texture types, but they are mostly interestingly
179-
different in their dimensions. These are distinct so that we can overload the
180-
various sample and texture load/store operations such that their parameters are
181-
appropriate to the type.
182-
183-
.. list-table:: Texture Fields
184-
:header-rows: 1
185-
186-
* - Field
187-
- Description
188-
* - ElementType
189-
- Type for a single element, such as ``i8``, ``v4f32``, or a structure
190-
type.
191-
* - IsWriteable
192-
- Whether or not the field is writeable. This distinguishes SRVs (not
193-
writeable) and UAVs (writeable).
194-
* - SampleCount
195-
- Sample count for a multisampled texture.
196-
* - FeedbackType
197-
- Feedback type for a feedback texture.
198-
199-
Raytracing Resources
200-
--------------------
201-
202-
.. code-block:: llvm
203-
204-
target("dx.RTAccelerationStructure")
205-
206-
.. note:: TODO: Describe RTAccelerationStructure
207-
208137
Resource Operations
209138
===================
210139

@@ -293,30 +222,6 @@ Examples:
293222
@llvm.dx.handle.fromBinding.tdx.Buffer_i8_0_0t(
294223
i32 1, i32 8, i32 1, i32 0, i1 false)
295224
296-
; cbuffer cb0 {
297-
; float4 g_MaxThreadIter : packoffset(c0);
298-
; float4 g_Window : packoffset(c1);
299-
; }
300-
%cb0 = call target("dx.CBuffer", 32)
301-
@llvm.dx.handle.fromBinding.tdx.CBuffer_32t(
302-
i32 0, i32 0, i32 1, i32 0, i1 false)
303-
304-
; Texture2D<float4> ColorMapTexture : register(t3);
305-
%tex = call target("dx.Texture2D", <4 x f32>, 0, 0)
306-
@llvm.dx.handle.fromBinding.tdx.Texture2D_v4f32_0_0t(
307-
i32 0, i32 3, i32 1, i32 0, i1 false)
308-
309-
; Texture1D<float4> Buf[5] : register(t3);
310-
; Texture1D<float4> B = Buf[NonUniformResourceIndex(i)];
311-
%tex = call target("dx.Texture1D", <4 x f32>, 0, 0)
312-
@llvm.dx.handle.fromBinding.tdx.Texture1D_v4f32_0_0t(
313-
i32 0, i32 3, i32 5, i32 %i, i1 true)
314-
315-
; SamplerState ColorMapSampler : register(s0);
316-
%smp = call target("dx.Sampler", 0)
317-
@llvm.dx.handle.fromBinding.tdx.Sampler_0t(
318-
i32 0, i32 0, i32 1, i32 0, i1 false)
319-
320225
.. list-table:: ``@llvm.dx.handle.fromHeap``
321226
:header-rows: 1
322227

@@ -351,28 +256,6 @@ Examples:
351256
@llvm.dx.handle.fromHeap.tdx.Buffer_v4f32_1_0(
352257
i32 2, i1 false)
353258
354-
; struct S { float f; };
355-
; ConstantBuffer<S> CB = ResourceDescriptorHeap[0];
356-
%cb0 = call target("dx.CBuffer", 4)
357-
@llvm.dx.handle.fromBinding.tdx.CBuffer_4t(
358-
i32 0, i1 false)
359-
360-
; Texture2D<float4> ColorMapTexture : register(t3);
361-
%tex = call target("dx.Texture2D", <4 x f32>, 0, 0)
362-
@llvm.dx.handle.fromBinding.tdx.Texture2D_v4f32_0_0t(
363-
i32 0, i1 false)
364-
365-
; Texture1D<float4> Buf[5] : register(t3);
366-
; Texture1D<float4> B = Buf[NonUniformResourceIndex(i)];
367-
%tex = call target("dx.Texture1D", <4 x f32>, 0, 0)
368-
@llvm.dx.handle.fromHeap.tdx.Texture1D_v4f32_0_0t(
369-
i32 %i, i1 true)
370-
371-
; SamplerState ColorMapSampler = ResourceDescriptorHeap[3];
372-
%smp = call target("dx.Sampler", 0)
373-
@llvm.dx.handle.fromBinding.tdx.Sampler_0t(
374-
i32 3, i1 false)
375-
376259
Buffer Loads and Stores
377260
-----------------------
378261

@@ -583,220 +466,3 @@ Examples:
583466
call void @llvm.dx.bufferLoad.tdx.Buffer_sl_i32f32f64s_0_0t.f32(
584467
target("dx.Buffer", {i32, f32}, 0, 0) %buf, i32 %index, i32 1, f32 %data)
585468
586-
Constant Buffer Loads
587-
---------------------
588-
589-
*relevant types: CBuffer*
590-
591-
Loading from constant buffers is relatively straightforward, and we model it
592-
with a single intrinsic, `llvm.dx.cbufferLoad`. Similarly to how we handle
593-
``bufferLoad``, we allow the intrinsic to load a scalar or a vector of
594-
consecutive values as needed.
595-
596-
In DXIL there are two operations that load from a constant buffer -
597-
`cBufferLoad`_ and ` and `cbufferLoadLegacy`_. These names can be confusing
598-
because only ``cbufferLoadLegacy`` is widely supported by drivers. The "legacy"
599-
op loads 16 bytes of data from the buffer, which is generally 4 32-bit values
600-
or 2 64-bit values, whereas the largely unsupported replacement loads a scalar
601-
directly. These differences are minor and we can easily lower to either from
602-
our own generic intrinsic.
603-
604-
.. _cbufferLoadLegacy: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#cbufferloadlegacy
605-
.. _cbufferLoad: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#cbufferload
606-
607-
.. list-table:: ``@llvm.dx.cbufferLoad``
608-
:header-rows: 1
609-
610-
* - Argument
611-
-
612-
- Type
613-
- Description
614-
* - Return value
615-
-
616-
- The scalar or vector type to load.
617-
- Data loaded from the cbuffer.
618-
* - ``%cbuffer``
619-
- 0
620-
- ``target(dx.CBuffer, ...)``
621-
- The constant buffer to load from
622-
* - ``%offset``
623-
- 1
624-
- ``i32``
625-
- Byte offset to load from
626-
627-
Examples:
628-
629-
.. code-block:: llvm
630-
631-
%ret = call float @llvm.dx.cbufferLoad.f32.tdx.CBuffer_16t(
632-
target("dx.CBuffer", 16) %cbuffer, i32 2)
633-
%ret = call <4 x float> @llvm.dx.cbufferLoad.v4f32.tdx.CBuffer_64t(
634-
target("dx.CBuffer", 16) %cbuffer, i32 0)
635-
636-
.. note:: TODO: Again, do we need alignment or can we rely on types here?
637-
638-
Texture Load and Store
639-
----------------------
640-
641-
*relevant types: Textures*
642-
643-
.. note:: TODO: The texture load and store operations in DXIL have *a lot* of
644-
parameters, and they use an awkward trick where which ones are valid
645-
and which *must* be ``undef`` depends on the texture type. I'd rather
646-
not copy that approach.
647-
648-
We have a few options:
649-
650-
1. Encode the dimensions into the operation in a way similar to the
651-
approach described below in the ``GetDimensions`` section. I
652-
showed that approach there because here is a bit less tractable.
653-
2. Encode the dimensions as types on the ``dx.Texture`` target type.
654-
This gives us uniform structure of the operations at the expense
655-
of them being more awkward to work with.
656-
657-
GetDimensions
658-
-------------
659-
660-
*relevant types: All Texture and Buffer types*
661-
662-
.. note:: TODO: This approach needs discussion. See the commentary in texture
663-
loads and stores above.
664-
665-
Looking up a resource's dimensions is done via a family of ``GetDimensions``
666-
intrinsics. The equivalent `DXIL operation <GetDimensions_>`_ returns ``{ i32,
667-
i32, i32, 32 }`` regardless of which dimensions are relevant for the resource,
668-
which can be confusing. Instead, we define variants of the form
669-
``GetDimensions.xyzsm`` where the returned elements are represented by an
670-
initial:
671-
672-
- ``x`` is width
673-
- ``y`` is height
674-
- ``z`` is array size for 1D or 2D arrays, or depth for 3D textures
675-
- ``s`` is number of samples in a multisampled texture
676-
- ``m`` is the number of MIP levels in a mipmapped texture
677-
678-
The set of variants is not dynamic - these initials are always specified in
679-
this order and there are exactly 10 valid configurations.
680-
681-
.. _GetDimensions: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#getdimensions
682-
683-
.. list-table:: ``GetDimensions`` variants
684-
:header-rows: 1
685-
686-
* - Variant
687-
- Returns
688-
- Args
689-
- Resource types
690-
* - ``GetDimensions.x``
691-
- ``i32``
692-
- n/a
693-
- ``Buffer``, read-only ``Texture1D``
694-
* - ``GetDimensions.xm``
695-
- ``{i32, i32}``
696-
- ``%miplevel``
697-
- writeable ``Texture1D``
698-
* - ``GetDimensions.xy``
699-
- ``{i32, i32}``
700-
- n/a
701-
- read-only ``Texture2D`` and ``TextureCube``
702-
* - ``GetDimensions.xym``
703-
- ``{i32, i32, i32}``
704-
- ``%miplevel``
705-
- writeable ``Texture2D`` and ``TextureCube``
706-
* - ``GetDimensions.xyz``
707-
- ``{i32, i32, i32}``
708-
- n/a
709-
- readonly ``Texture2DArray``, ``Texture3D``, ``TextureCubeArray``
710-
* - ``GetDimensions.xyzm``
711-
- ``{i32, i32, i32, i32}``
712-
- ``%miplevel``
713-
- writeable ``Texture2DArray``, ``Texture3D``, ``TextureCubeArray``
714-
* - ``GetDimensions.xys``
715-
- ``{i32, i32, i32}``
716-
- n/a
717-
- ``Texture2DMS``
718-
* - ``GetDimensions.xyzs``
719-
- ``{i32, i32, i32, i32}``
720-
- n/a
721-
- ``Texture2DMSArray``
722-
723-
Examples:
724-
725-
.. code-block:: llvm
726-
727-
declare i32
728-
@llvm.dx.GetDimensions.x.tdx.Buffer_f32_0_0t()
729-
declare i32
730-
@llvm.dx.GetDimensions.x.tdx.Texture1D_f32_0_0t()
731-
declare {i32, i32}
732-
@llvm.dx.GetDimensions.xm.tdx.Texture1D_f32_1_0t(i32 %miplevel)
733-
declare {i32, i32}
734-
@llvm.dx.GetDimensions.xy.tdx.Texture2D_f32_0_0t()
735-
declare {i32, i32}
736-
@llvm.dx.GetDimensions.xz.tdx.Texture1DArray_f32_0_0t()
737-
declare {i32, i32, i32, i32}
738-
@llvm.dx.GetDimensions.xyzm.tdx.Texture3D_f32_1_0t(i32 %miplevel)
739-
declare {i32, i32, i32, i32}
740-
@llvm.dx.GetDimensions.xyzs.tdx.Texture2DMSArray_f32_1_0_1t()
741-
742-
Samples
743-
-------
744-
745-
*relevant types: Textures and Samples*
746-
747-
.. note:: TODO: Describe sampling.
748-
749-
The following DXIL operations are relevant:
750-
- ``Sample``
751-
- ``SampleBias``
752-
- ``SampleLevel``
753-
- ``SampleGrad``
754-
- ``SampleCmp``
755-
- ``SampleCmpLevelZero``
756-
757-
CalculateLOD
758-
------------
759-
760-
*relevant types: Textures and Samples*
761-
762-
.. note:: TODO: Describe ``CalculateLOD``.
763-
764-
TextureGather
765-
-------------
766-
767-
*relevant types: Textures and Samples*
768-
769-
.. note:: TODO: Describe ``TextureGather`` and ``TextureGatherCmp``.
770-
771-
Texture2DMSGetSamplePosition
772-
----------------------------
773-
774-
*relevant types: Texture2DMS and maybe Texture2DMSArray*
775-
776-
.. note:: TODO: Describe ``Texture2DMSGetSamplePosition``
777-
778-
Buffer Update Counter
779-
---------------------
780-
781-
*relevant types: RWStructuredBuffer?*
782-
783-
.. note:: TODO: Describe ``BufferUpdateCounter``
784-
785-
Note that we need to account for calculating HasCounter, as was mentioned in
786-
an earlier TODO.
787-
788-
Atomics
789-
-------
790-
791-
*relevant types: Textures and Buffers*
792-
793-
.. note:: TODO: Describe ``AtomicBinOp`` and ``AtomicCompareExchange``
794-
795-
Reflection Information
796-
======================
797-
798-
.. note:: TODO: Add some notes on the HLSL variable name and its relationship
799-
to reflection.
800-
801-
Ideally this would boil down to a link to a separate "reflection"
802-
document.

0 commit comments

Comments
 (0)