Граф коммитов

306 Коммитов

Автор SHA1 Сообщение Дата
Lei Zhang e3662ff353
[spirv] Collect global non-resource variables into $Globals (#1138)
This commit changes the behavior of how to handle externally-visiable
non-resource-type stand-alone variables. Previously they are emitted
as stand-alone SPIR-V variables. Now they are grouped into a cbuffer
that named as $Globals. This is more aligned with how DirectX handles
them.
2018-03-14 11:15:14 -04:00
Lei Zhang c133d935eb
[spirv] Support SM6.0 wave ops using Vulkan 1.1 (#1118)
Support promoting to SPIR-V 1.3 when necessary

Support SM6.0 wave query and vote ops

* WaveIsFirstLane
* WaveGetLaneCount
* WaveGetLaneIndex
* WaveActiveAnyTrue
* WaveActiveAllTrue
* WaveActiveBallot

Support SM6.0 wave reduction ops

* WaveActiveAllEqual
* WaveActiveCountBits
* WaveActiveSum
* WaveActiveProduct
* WaveActiveBitAnd
* WaveActiveBitOr
* WaveActiveBitXor
* WaveActiveMin
* WaveActiveMax

Support SM6.0 wave scan/prefix ops

* WavePrefixSum
* WavePrefixProduct
* WavePrefixCountBits

Support SM6.0 wave broadcast ops

* WaveReadLaneAt
* WaveReadLaneFirst

Support SM6.0 quad-wide shuffle ops

*  QuadReadAcrossX
*  QuadReadAcrossY
*  QuadReadAcrossDiagonal
*  QuadReadLaneAt
2018-03-13 15:24:48 -04:00
Lei Zhang c859bb040f
[spirv] Support SPV_KHR_shader_draw_parameters (#1127)
Added support for the following SPIR-V builtins exposed in
SPV_KHR_shader_draw_parameters:
* BaseVertex
* BaseInstance
* DrawIndex
2018-03-13 10:07:54 -04:00
Tex Riddell cb5f27c080 Merge branch 'master' into user/texr/rt-merge-rebase 2018-03-12 13:11:12 -07:00
Lei Zhang 26bf35450a
[spirv] Update doc about reflection (#1130) 2018-03-12 11:32:00 -04:00
Lei Zhang 70990344ed
[spirv] Implement relaxed layout for vector types (#1092)
Based on GLSL std140/std430 layout rules, relaxed layout allows
using vector's element type's alignment as the vector types's
alignment, so that we can pack a float value and a float3 value
tightly. This is the default right now.

Also add an option, -fvk-use-glsl-layout, to turn off the relaxed
layout for vectors and use conventional GLSL std140/std430 layout
rules.
2018-03-12 10:21:54 -04:00
Tex Riddell f8e1af0417 Merge branch 'master' into user/texr/rt-merge-rebase 2018-03-09 00:55:21 -08:00
Lei Zhang 451d095898
[spirv] Update doc about texture concepts (#1123) 2018-03-08 12:11:09 -05:00
Ehsan b02d940813
[spirv] Don't emit Float16 capability. (#1109)
Capability Float16 is not allowed by Vulkan 1.0 specification.
SPV_AMD_gpu_shader_half_float should be used if 16bit floats are used.
2018-03-06 11:25:20 -05:00
Lei Zhang c1ea245a16
[spirv] Add support for WaveReadLineFirst() (#1106) 2018-03-01 15:48:09 -05:00
Young Kim 81ecfef34b
Fix denorm preserve division with high value of denominator (#1093) 2018-03-01 07:41:10 -08:00
Lei Zhang c8970cdf6b
[spirv] Ignore static when seeing both static and groupshared (#1101) 2018-02-28 12:12:13 -05:00
Tex Riddell 914c040b14 Merged PR 26: Fix intrinsic names to match spec.
Fix intrinsic names to match spec.

- PrimitiveIndex still maps to low level dx.op.primitiveID
2018-02-21 21:51:20 +00:00
Lei Zhang 5c4ca12efc
[spirv] Update doc and SPIRV-Tools (#1088)
Add explanation of legalization, optimization, validation in doc.
2018-02-21 14:12:01 -05:00
Lei Zhang 4221a698e1
[spirv] Support WaveGetLaneCount() and WaveGetLaneIndex() (#1077)
They are translated into SPIR-V builtin varibles. The translation
requires the SPV_KHR_shader_ballot extension.
2018-02-21 10:34:01 -05:00
Tex Riddell 7d145d64d5 Merge branch 'master' into user/texr/rt-merge-rebase 2018-02-12 17:51:50 -08:00
Ehsan 774e85eb20 [spirv] Add initial support for non-fp matrices (#1057)
This is the support for non-floating-point matrices,
which are emulated using arrays of vectors because
SPIR-V does not allow non-floating-point matrices.

* Initial support for non-fp matrix
* Add support for non-fp matrix in all()
* Conversion of float matrix to int matrix
* support for modf returning an int matrix
* Add tests for non-fp matrix access
* Mixed arithmetic for non-fp matrices
* Support non-fp matrix in flat conversion
* Non-fp matrix in asint/asuint/asfloat
* Mul of non-fp Matrix with Vector/Scalar
* Add tests for non-fp matrix cast

TODO: Layout decoration of non-fp matrices
TODO: Majorness of non-fp matrices
2018-02-12 15:33:41 -05:00
Xiang Li fdf2c31ca6 1. Fix IgnoreHit and AcceptHitAndEndSearch.
2. Support init list for RayDesc.
3. Remove range_id for lib.
4. Update some test.
2018-02-05 18:51:47 -08:00
Xiang Li 519938f12e Lower HLCreateHandle into CreateHandleFromResourceStructForLib. 2018-02-05 17:54:07 -08:00
Xiang Li c45aa784ac Add AcceptHitAndEndSearch, CallShader, CommitHitAndStopRay and change ReportIntersection into ReportHit.
Also change RayTracingAccelerationStructure into RaytracingAccelerationStructure.
2018-02-05 17:54:06 -08:00
Xiang Li eb4b0ae768 Support user define type for dxil operation.
Add RayTracingAccelerationStructure to dxil resource.
Lower ReportIntersection and TraceRay.
2018-02-05 17:54:05 -08:00
Lei Zhang 240a5d8e7f
[spirv] Wrap global matrix variables in structs (#1050)
According to HLSL doc, "variables that are placed in the global scope
are added implicitly to the $Global cbuffer, using the same packing
method that is used for cbuffers."

But we emit all global variables as stand-alone SPIR-V variables.
This causes issues for matrix variables since we cannot annotate
them with majorness decoration anymore.

Wrap global matrix variables in a struct to solve the problem.
2018-02-02 12:44:48 -05:00
Ehsan d7e95a7f3c
[spirv] Explain reasoning of matrix representation (#1048) 2018-02-01 15:21:17 -05:00
Lei Zhang 14c3c0d92c
[spirv] Add initial support for specialization constant (#1009)
This commit add support for generating OpSpecConstant* instructions
with SpecId decorations. Spec constants are only allowed to be of
scalar boolean/integer/float types. Using spec constant as the array
size does not work at the moment.
2018-01-22 15:36:14 -05:00
Lei Zhang 4cbada6181
[spirv] Translate SubpassInput(MS) and their methods (#1013) 2018-01-22 10:45:56 -05:00
Lei Zhang 6af2a123d8
[spirv] Add support for .GetSamplePosition() (#1008)
This only supports .GetSamplePosition() for standard sample
positions, i.e., sample count is 1, 2, 4, 8, or 16. For other
cases, the method will just return float2(0, 0).
2018-01-19 16:00:23 -05:00
Lei Zhang f9d613b795
[spirv] Add support for -fvk-invert-y (#967)
This is to accommodate Vulkan's coordinate system, which is different
from DX's.
2018-01-08 11:42:47 -05:00
Ehsan eeab612da9
[spirv] 16-bit and 64-bit int, uint, and float. (#966)
* [spirv] 16-bit and 64-bit int, uint, and float.

* Added Int64, Uint64, Int16, Uint16.
* Added 16-bit float constants.
* Get the -enable-16bit-types cmd option.
* Add tests for constant Int64/Uint64/Int16/etc.
2018-01-05 16:52:15 -05:00
Lei Zhang d39c94c56f
[spirv] Emit warning for packoffset (#951)
We do not support packoffset right now. Emit warning and ignore it.
2018-01-03 10:13:04 -05:00
Lei Zhang cf39455abf
[spirv] Update doc about variable storage classes (#945) 2017-12-20 18:34:25 -05:00
Xiang Li b816c124f1
Support resource select for lib profile. (#940) 2017-12-20 10:47:29 -08:00
Ehsan fc52dbced0
[spirv] Document missing pow2 partitioning feature. (#937)
* [spirv] Document missing pow2 partitioning feature.
* Provide more accurate location for attributes.
2017-12-19 13:37:48 -05:00
Ehsan cb4e570b82
[spirv] warn {row|col}_major on standalone matrix. (#935) 2017-12-18 16:48:16 -05:00
Ehsan 1d4509f35d
[spirv] Support Load methods that take Status arg. (#905) 2017-12-12 17:38:30 -05:00
Ehsan 679b7c80c7
[spirv] Support CheckAccessFullyMapped intrinsic. (#897) 2017-12-11 14:02:21 -05:00
Lei Zhang 5de265fddb
[spirv] Add support for ignoring unused resources (#875)
Added a new command line option -fvk-ignore-unused-resources
to avoid emitting SPIR-V code for resources defined but not statically
referenced by the call tree of the entry point in question.
2017-12-05 12:21:55 -05:00
Lei Zhang 53f3f69b36
[spirv] Add mechanism for Vulkan-specific builtins (#805)
[[vk::builtin("...")]] is introduced to support Vulkan-specific
builtins.

There are two supported in this commit:

* gl_PointSize
* gl_HelperInvocation

Validating the usages of these two builtins is left for anther
commit.
2017-11-25 17:32:39 -08:00
Lei Zhang 9745b0d55c
[spirv] Add support for SV_Barycentrics (#837)
The translation is done using  SPIR-V Extension
SPV_AMD_shader_explicit_vertex_parameter.
2017-11-22 18:16:48 -05:00
Lei Zhang d1f1665865
[spirv] Add support for SV_ViewID (#836)
Also error out on seeing unknown patch constant function parameter.
2017-11-22 18:16:15 -05:00
Ehsan 06aadc4789
[spirv] CheckAccessFullyMapped unsupported error (#824) 2017-11-20 08:45:43 -05:00
Lei Zhang 4a4d1134ef
[spirv] Emit unsupported error for some intrinsics (#797)
* abort
* GetRenderTargetSampleCount
* GetRenderTargetSamplePosition
* GatherCmpGreen
* GatherCmpBlue
* GatherCmpAlpha
* GetSamplePosition
* CalculateLevelOfDetailUnclamped
2017-11-16 14:23:03 -05:00
Lei Zhang 83e23e6954
[spirv] Add support for SV_Coverage (#800)
Also emit an error for SV_InnerCoverage.
2017-11-15 12:02:27 -05:00
Ehsan 576a805117
[spirv] Translate intrinsic dst function. (#801) 2017-11-15 10:14:24 -05:00
Lei Zhang 6788ebea4a
[spirv] Add support for [[vk::push_constant]] (#791)
[[vk::push_constant]] can be attached to a global variable of
struct type to put that variable in the PushConstant storage
class.

PushConstant should be of OpTypeStruct type with std430 layout.
2017-11-15 08:14:22 -05:00
Ehsan b32bc384a3
[spirv] Translate intrinsic D3DCOLORtoUBYTE4. (#799) 2017-11-14 11:09:51 -05:00
Lei Zhang 0d462693b5
[spirv] Add support for SV_ViewportIndex (#796) 2017-11-14 10:56:53 -05:00
Lei Zhang e9a2c759b5
[spirv] Support SV_RenderTargetArrayIndex and SV_StencilRef (#789) 2017-11-13 14:44:04 -05:00
Ehsan 4d97841e33
[spirv] Translate *MemoryBarrier* intrinsics. (#790)
* Translation of GroupMemoryBarrier(WithGroupSync)
* Translation of DeviceMemoryBarrier(WithGroupSync)
* Translation of AllMemoryBarrier(WithGroupSync)
2017-11-13 14:08:13 -05:00
Lei Zhang e40535653f
[spirv] Emit Invocations execution mode in GS (#793)
OpExecutionMode Invocations n should be emitted for [instance(n)]
on GS. n defaults to 1.
2017-11-13 10:43:31 -05:00
Ehsan 4bd93f66a3
[spirv] tbuffer and TextureBuffer support. (#787) 2017-11-10 17:07:43 -05:00
Lei Zhang a579b3eaef
[spirv] Add support for f16tof32() and f32tof16() (#786)
Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/785
2017-11-10 12:31:52 -05:00
Lei Zhang 68ef628bd9
[spirv] Complete the support for SV semantics in all stages (#775)
Covers the following SVs for all their legal SigPoints:

* SV_Position
* SV_ClipDistance
* SV_CullDistance
* SV_VertexID
* SV_InstanceID
* SV_Depth
* SV_DepthGreaterEqual
* SV_DepthLessEqual
* SV_OutputControlPointID
* SV_DomainLocation
* SV_GSInstanceID
* SV_IsFrontFace
* SV_DispatchTreadID
* SV_GroupID
* SV_GroupThreadID
* SV_GroupIndex
* SV_TessFactor
* SV_InsideTessFactor
* SV_PrimitiveID
* SV_SampleIndex
2017-11-10 11:47:50 -05:00
Lei Zhang 37eade8495
[spirv] Add support for basic geometry shader (#772)
This commit supports .Append() and .RestartStrip() method calls
on stream-output objects, which will be translated into SPIR-V
OpEmitVertex and OpEndPrimitive, respectively.

For each .Append() call, all affected stage output variables
will be flushed.
2017-11-08 11:41:43 -05:00
Lei Zhang 87d66c9d09
[spirv] Add doc and tests for snorm/unorm float type (#773) 2017-11-08 10:49:32 -05:00
Young Kim 2c140f795c
RawBufferLoad and new methods for ByteAddressBuffer (#762)
This change is an extension of float16 support. We are adding LoadHalf, LoadFloat, and LoadDouble method to byte address buffer so that users can access data from byte address buffer by these types. Also starting shader model 6.2, we are mapping byte address buffer and structure buffer load/store operations to RawBufferLoad/Store to differentiate raw buffer load from typed buffer load. Unlike BufferLoad for typed buffers, RawBufferLoad for min precision types will not have its min precision values as its return types, but their actual scalar size in buffer (i.e rawBufferLoad.i32 for min16int and rawBufferLoad.f32 for min16float). RawBufferLoad/Store contains additional parameters, where mask was required for correct status behavior for CheckAccessFullyMapped, and alignment is for relative alignment for future potential benefit for backend.
2017-11-07 18:15:19 -08:00
Lei Zhang dc3d2c7921
[spirv] Require ClipDistance/CullDistance capability on use (#769)
Declaring but not using (reading/writing) ClipDistance/CullDistance
does not require the ClipDistance/CullDistance capability.
2017-11-07 15:17:13 -05:00
Lei Zhang 734266277b
[spirv] Change vertex processing stages to emit gl_PerVertex (#757)
As per the Vulkan spec requirement:

  Any variable decorated with Position must be declared as a
  four-component vector of 32-bit floating-point values.

But for HS/DS/GS, we actually have an extra arrayness. If we
generate a stand-alone Postion builtin variable, it will be
an array of float4, which does not comply with the spec.

Similary for the type requirements on ClipDistance and
CullDistance.

The spec could have an problem on this issue, but the GLSL way
is to emit a gl_PerVertex that contains Position, ClipDistance,
and CullDistance. That satisfies the current Vulkan spec.

This commit converts VS output, HS/DS input and output, GS
input to emit the gl_PerVertex struct. It also splits arrays
of structs into arrays of the fields for HS/DS/GS input/output.

ClipDistance/CullDistance is also supported in this commit,
which requires quite some non-trivial handling.
2017-11-07 09:56:10 -05:00
Young Kim 8c55bbbe6d
Denorm to function attribute (#764)
- Denorm mode to function attribute not function annotation
- Adding validation rule for fp32-denorm-mode



* Fix from comments
2017-11-06 18:09:14 -08:00
Xiang Li d8cefeb1ba
Make sure status only used by CheckAccessFullyMapped. (#763)
* Make sure status only used by CheckAccessFullyMapped.
2017-11-03 18:12:15 -07:00
Ehsan 97aab11faf
[spirv] Translate intrinsic asdouble and asuint. (#758) 2017-11-03 05:38:08 -07:00
Ehsan 4b7fab259f
[spirv] Add support for HLSLMatrixTruncationCast (#753) 2017-11-03 05:37:46 -07:00
Ehsan c5dc49a7fd
[spirv] Translate intrinsic Lit function. (#744) 2017-10-31 10:14:56 -04:00
Ehsan 6d8bf3e34a [spirv] Support GS output stream types. (#736) 2017-10-26 14:02:40 -04:00
Ehsan 96c5c0ad17 [spirv] Execution modes for GS primitive types. (#734) 2017-10-25 16:02:23 -04:00
Ehsan 0d9cfd2b3a [spirv] Translate maxvertexcount attribute for GS. (#732) 2017-10-25 09:25:38 -04:00
Lei Zhang ffe7692c75 [spirv] Update SPIR-V rst doc (#733) 2017-10-24 14:32:38 -04:00
Lei Zhang 108f1658d2 [spirv] Add support for [[vk::counter_binding(X)]] (#730)
A new attribute [[vk::counter_binding(X)]] can be used to specify
the binding number for associated counters for RW/append/consume
structured buffers.

Also added support for .IncrementCounter() and .DecrementCounter()
for RWStructuredBuffer.

Also fixed the type error of OpAtomicI{Add|Sub}.
2017-10-24 10:51:50 -04:00
Lei Zhang 5686ccf2c4 [spirv] Allow the same binding number for combined image sampler (#729)
Vulkan combined image sampler is logically considered a sampled
image and a sampler bound together.
2017-10-23 11:57:40 -07:00
Lei Zhang 8702f97dff [spirv] Add support for four register number shifting options (#720)
Added the following four command line options to shift register
number for Vulkan:

* -fvk-b-shift
* -fvk-t-shift
* -fvk-s-shift
* -fvk-u-shift

These options are used to avoid assigning the same binding
number to more than one resources.
2017-10-20 19:37:11 -07:00
Lei Zhang 9cb179024b [spirv] Add support for struct/class static members (#714)
These static members are translated into SPIR-V variables of
the Private storage class.
2017-10-17 07:46:08 -07:00
Ehsan 2fa7a957a0 [spirv] Add translation for intrinsic rcp. (#713)
Also includes creating 64-bit float constants that are needed for
reciprocating a 64-bit float.
2017-10-17 08:53:00 -04:00
Ehsan 78ac89a6f8 [spirv] Documentation of hull shader translation. (#702) 2017-10-16 15:47:29 -04:00
Ehsan 0888e319e7 [spirv] Intrinsic fwidth & faceforward (#711) 2017-10-16 13:53:08 -04:00
Ehsan 8afee2994c [spirv] Intrinsic ddx and ddy. (#707)
Also:
* ddx_coarse, ddx_fine
* ddy_coarse, ddy_fine
2017-10-16 10:11:29 -04:00
Lei Zhang 2e1ea68d6c [spirv] Add support for texture .GatherCmpRed() method (#700) 2017-10-13 11:21:38 -04:00
Lei Zhang 52372b1186 [spirv] Add support for texture .GatherCmp() method (#697) 2017-10-12 15:35:29 -04:00
Lei Zhang 050755b4d8 [spirv] Add support for .SampleCmp() and .SampleCmpLevelZero() (#689) 2017-10-12 11:34:38 -04:00
Lei Zhang 3a6f80eb1b [spirv] Add support for .GatherRGBA() methods on texture types (#682)
Also extended tests for .Gather() tests to cover scalar element
types and vector element types with less than 4 components.
2017-10-10 15:36:37 -04:00
Lei Zhang 102fe247f1 [spirv] Support RWByteAddressBuffer atomic methods (#678) 2017-10-06 09:59:13 -04:00
Lei Zhang c757514869 [spirv] Tweak binding number assignment scheme (#675)
Now we essentially assign binding numbers to all resources in
three passes: [[vk::binding(...)]], register(...), and then
no annotation.
2017-10-03 11:12:08 -04:00
Lei Zhang 49313dd16e [spirv] Update mapping manual (#665) 2017-09-29 14:56:10 -04:00
Ehsan 58612be9f3 [spirv] More compute shader semantics. (#662)
* SV_GroupID
* SV_GroupIndex
* SV_GroupThreadID
2017-09-28 17:43:18 -04:00
Ehsan a0684306a6 [spirv] GetDimension for ACSBuffer. (#658)
GetDimensions for AppendStructuredBuffer
GetDimensions for ConsumeStructuredBuffer
2017-09-28 12:15:32 -04:00
Ehsan 015bdfd1d7 [spirv] Translate several intrinsic functions. (#654)
* frexp
* countbits
* clip
* ldexp
* lerp
* log10
* mad
* modf
* reversebits
2017-09-28 10:28:46 -04:00
Ehsan 52c27ffbbd [spirv] CalculateLevelOfDetail for Texture types. (#653) 2017-09-27 14:15:32 -04:00
Ehsan 746d8ea5ed [spirv] Update doc for ByteAddressBuffer methods. (#652)
* [spirv] Update doc for ByteAddressBuffer methods.

* Better doc.
2017-09-26 09:19:22 -07:00
Ehsan a62fc13575 [spirv] Translation of several intrinsic functions (#639)
* [spirv] Translation of several intrinsic functions

Translation for the following intrinsic functions:

* Matrix transpose
* smoothstep
* refract
* distance
* isinf
* isnan
* isfinite
* sincos
* saturate
* atan2
* fma
* fmod
* frac
* firstbithigh
* firstbitlow

* Address code review comments.
2017-09-26 09:18:23 -07:00
Ehsan 00b7505afd [spirv] GetDimensions for several types. (#636)
* [spirv] GetDimensions for several types.

GetDimensions function implementation for:
Textures, RWTextures,
Buffers, RWBuffers,
ByteAddressBuffers, RWByteAddressBuffers,
StructuredBuffers, RWStructuredBuffers.

* Address comments.

* Update the doc file.
2017-09-25 09:23:06 -07:00
Lei Zhang 809495a4c2 [spirv] Update mapping manual (#634) 2017-09-20 20:28:22 -07:00
Ehsan 479f1cd9bf [spirv] Support other primitive int/float types. (#628)
* [spirv] Support other primitive int/float types.

* Address comments.
2017-09-20 20:26:07 -07:00
Young Kim 223a885613 Group Signature Elements by Element Width (#610)
This change is to enforce the new constraint on signature packing: pack signature elements by data width. Before we introduce fp16 type, every element was assumed to reserve 32 bits. Since we are introducing a new 16 bit data type, we need a new way to enforce signature rules.

After discussions we decided that it would be nice to pack elements based on data width. However, we are still enforcing the rule that each row contains up to 4 elements, regardless of the size. This way, depending on the hardware support drivers can optimize packing signatures, while on DXIL level we maintain the assumption that there are 4 elements per row. We are also still constraining on the total number of rows to be 32 for now. This can be changed in the future if people find this limit to be an issue.
2017-09-06 11:04:33 -07:00
theswiftfox e97dd2a0cd Fix typo in SPIR-V.rst (#612)
HLSL semantic and Vulkan ``Loation`` -> HLSL semantic and Vulkan ``Location``
2017-09-01 13:37:36 -07:00
Ehsan 7a0ae9e90b RWTexture Load() and Texture2DMS(Array) (#609)
* [spirv] OpImageRead can read a vector of any size.

* [spirv] Add support for Load() of RWTexture types.

* [spirv] Texture2DMS and Texture2DMSArray types.

* [spirv] Capability for 1D images without a sampler

* [spirv] Update documentation of Texture2DMS(Array)
2017-08-31 16:10:13 -07:00
Ehsan d5592ce089 [spirv] Add translation of RWTexture... types. (#602)
* [spirv] Add translation of RWTexture... types.
* Update documentation for RWTexture types.
* Fix table formatting in doc.
2017-08-29 14:57:54 -07:00
Lei Zhang bc1301af13 [spirv] Update SPIR-V.rst doc (#596)
Moved logistics and designs to the wiki page. Now the doc is only
for HLSL to SPIR-V mappings.

Also link to the doc and wiki page in the main README.md.
2017-08-25 08:56:42 -07:00
Lei Zhang 0e0e014232 [spirv] Add CL option for stage I/O location assignment order (#578)
A new CL option -fvk-stage-io-order={alpha|decl} is added to
control the order for assigning stage I/O location numbers.
The default is also changed to declaration order (decl) instead
of alphabetical order (alpha).

Also extended testing fixtures to support additional CL options.
2017-08-17 20:59:45 -07:00
Lei Zhang 65d17b4f7c [spirv] Support setting resource binding numbers (#577)
This commit add support for resource binding number assignment via
both the explicit and the implicit way.

The explicit way:

[[vk::binding(X[, Y])]] is introduced, with X denoting the binding
number and the optional Y denoting the set number. If Y is missing,
the set number will be set to 0. This attribute can only be attached
to variables.

The implicit way:

register(xX, spaceY) will be used to deduce the correct set and
binding number for a given resource. X will be used as the binding
number and Y will be used as the set number. Right now we do not
consider the resource type x, which means binding numbers can
overlap given the same X and Y but not x. That is to be addressed
later.
2017-08-17 20:56:48 -07:00
Lei Zhang f284c982c9 [spirv] Support texture and sampler types (#572)
This commit add support for the following types:
* Texture1D, Texture2D, Texture3D, TextureCube
* Texture1DArray, Texture2DArray, TextureCubeArray
* SamplerState, SamplerComparisonState, sampler

Buffer, Texture2DMS, and Texture2DMSArray is not supported yet,
also setting sampler states.

Texture types will be translated OpTypeImage, and sampler types
will be translated into OpTypeSampler.
2017-08-16 21:09:20 -07:00
Lei Zhang a727fc8838 [spirv] Support PS SV_Depth{Greater|Less}Equal and SV_IsFrontFace (#563) 2017-08-14 13:43:05 -07:00
Lei Zhang 6fd778c14a [spirv] Update SPIR-V.rst doc (#558)
* Restructured sections
* Explained how HLSL semantics are handled
* Highlighted source code
2017-08-14 09:32:43 -07:00
Lei Zhang d98d66564a [spirv] Converted to generate wrapper for entry function (#557)
Previously for an entry function, we decompose its parameters and
return value and create stage input/output/builtin variables from
them directly. This is fine for simple shaders, but it will have
problems for shaders using structs to group stage variables.
Accessing paramters and return values (using operator. and return)
needs special handling for entry functions, which is nasty.

With the wrapper function, we can handle entry functions just like
normal functions. Stage variable handling are all done in the
wrapper funtion.
2017-08-11 16:08:27 -07:00
Lei Zhang 1da87c6aaf [spirv] Handle static global and local variables (#541)
These variables should be using the Private storage class.
And local static variables should be initialized once.
2017-08-09 15:31:20 -07:00
Ehsan ff65329ee2 [spirv] Translate more instrinsic functions (#537)
Using GLSL 450 extended instruction set to translate some HLSL
intrinsic functions.
2017-08-09 09:43:27 -07:00
Ehsan ec9cfae3b6 [spirv] Translation of while loops (#532)
Also added the translation for `loop` and `unroll` attributes.

Similar to for loops, the current implementation does not support
early exits, or early returns.
2017-08-08 22:18:51 -07:00
Lei Zhang d3d5dd789d [spirv] Add doc for vector and matrix types (#507) 2017-08-02 16:27:56 -07:00
Lei Zhang 694c35a47e [spirv] Translate vector truncation and splatting (#502)
* [spirv] Translate vector truncation and splatting

* Also added tests for vector<|type|, |count|> format.

* [spirv] Remove duplicated vector splatting tests

Although they appear as binary operator tests, they are essentially
testing vector splatting, which we already have dedicated tests.
2017-08-02 09:38:20 -07:00
Lei Zhang c760e02232 [spirv] Support casting to bool/int/float (vector) values (#500)
* [spirv] Translate casting to bool (vector) values

* Supported converting scalar/vector sint/uint/float values into
  scalar/vector bool values.

* [spirv] Translate casting to int (vector) values

* Supported converting scalar/vector bool/float values into
  scalar/vector sint/uint values.

* [spirv] Translate casting to float (vector) values

* Supported implicit/explicit casting from scalar/vector
  bool/sint/uint into scalar/vector float values
2017-08-01 16:31:25 -07:00
Lei Zhang f38109c154 [spirv] Translate boolean math operators: &&, ||, ?: (#499) 2017-08-01 11:25:32 -07:00
Lei Zhang c8ff1681be [spirv] Support unary operators: ++, --, !, +, - (#497)
* [spirv] Translate prefix/postfix increment/decrement

* [spirv] Translate unary operator !, +, and -
2017-08-01 09:10:48 -07:00
Ehsan e6685a310d [spirv] Translate intrinsic dot product. (#496)
The translation supports dot product of vectors of floats using
SPIR-V's OpDot.

The translation also supports dot product of vectros of integers
using multiplication and addition.
2017-07-31 18:09:02 -07:00
Lei Zhang 399e987298 [spirv] Translate bitwise operators (#495)
* Covers ~, &, |, ^, <<, >>, &=, |=, ^=, <<=, >>=
* For int/uint and vector of int/uint
2017-07-31 16:14:59 -07:00
Lei Zhang 660a367778 [spirv] Vector types, variable initializers, and comparison (#488)
* [spirv] Translate vector types and handle variable initializers

* Translated vector types and operations on vector types
  * +, -, *, /, % on vector <op> vector and vector <op> scalar
  * Prefix increment on vectors
  * < on vector <op> vector and vector <op> scalar
* Covered both constant initializer and variable initializer
* Applied constant modifier to variables

* [spirv] Translate all comparision operators

* Covers <, <=, >, >=, ==, !=
* For both scalars and vectors
* Also update docs about arithmetic and comparison operators
2017-07-31 09:13:45 -07:00
Lei Zhang dc240f47e7 [spirv] Translate non-entry functions and function calls (#487) 2017-07-28 08:59:49 -07:00
Young Kim 55667043c3 Support denorm option (#446)
This change is to support preserve denorm operations. We do this by creating dxc options and propagate them all the way to dxil metadata so that drivers can see how it should handle floats.
Currently we support three modes: any(default), preserve, and ftz

Denorm option will be of per function flag. We store this information at function annotation metadata. This means that for DXIL 1.2 we have a new structure for function annotation. The change in structure is documented on DXIL.rst
2017-07-27 10:08:14 -07:00
Young Kim 7f65e0f0d6 Clean up crlf and mixed line ending issues. (#391) 2017-06-29 16:26:20 -07:00
Xiang Li 25a864b578 Update doc for lib_6_1 profile.
Also fix build error caused by lost arg for DXASSERT_LOCALVAR.
2017-06-19 15:40:23 -07:00
Xiang Li 85063375b3 Add attribute to mark shader entry. 2017-06-19 15:15:43 -07:00
yurido1 0c38e360b2 Update DXIL.rst 2017-05-31 13:17:43 -07:00
yurido1 ff050a9f18 Update DXIL.rst 2017-05-24 16:22:46 -07:00
yurido1 9bb44240f7 Update DXIL.rst 2017-05-23 17:21:39 -07:00
yurido1 8fd85f16d5 Changed DS to use LoadInput instead of LoadOutputControlPoint 2017-05-19 17:25:57 -07:00
Young Kim f66e8083d6 Allow two SV_Barycentrics (#282)
unlike other system value semantics, pixel shader is allowed to declare at most two input attributes with SV_Barycentrics, with one declaration uses perspective interpolation type while other one uses noperspective interpolation type.
2017-05-09 18:59:30 -07:00
Marcelo Lopez Ruiz ad76d814a4 Debug name part implementation (#264)
* Add documentation with source-level debugging with HLSL and DXIL.
* Fix trailing underscore in generate .rst documentation.
* Add container support for debug name part.
* Bump validator version to 1.1.
* Implement debug stripping in dxc, including /Fd dir-named behavior.
* Implement IDxcCompiler2 and CompileWithDebug.
2017-05-09 18:32:48 -07:00
Young Kim 13cf7d466c Update barycentric with new spec (#265)
1. Adding SV_Barycentric and removing barycentric intrinsics/dxilops
2. GetAttributeAtVertex only thakes no_interpolation attribute
3. SV_Barycentric can take any interpolation modifier except nointerpolation
4. SV_Barycentric can only have float3 type
2017-05-03 17:07:02 -07:00
yurido1 7b98cc8efc Update DXIL.rst (#267)
Fixed Htan behavior for +/- INF.
2017-05-02 15:24:47 -07:00
yurido1 b3925dbb34 Update DXIL.rst (#261)
Fixed input/output intrinsics table for HS and DS.
2017-05-02 14:10:18 -07:00
Tex Riddell bd6c105e9b Add ViewID slot validation for PSIn (#254) 2017-05-01 17:54:33 -07:00
Tex Riddell a581927370 Add SV_ViewID support (#251)
- Add SV_ViewID loaded from intrinsic in Dxil,
  for input to all graphics shader stages
- hctdb: rename shader_models to shader_stages,
  add shader_model for min required shader model
- Validator: validate dxil version required for shader model
- DxilModule: Add GetDxilVersion
- Set Barycentric intrinsics to SM 6.1
- Update SystemValueTest for SM 6.1
2017-04-27 14:17:31 -07:00
Young Kim 108b897f40 Barycentric init (#250)
This change is the initial step to support Barycentric coordinates for shader model 6.1 / DXIL 1.1
 - Add GetBarycentrics, GetAttributeAtVertex intrinsics and their corresponding dxil ops
 - Lowering intrinsics to dxil ops
 - Adding codegen tests for these operations
2017-04-26 12:29:48 -07:00
Young Kim 4f3355b8f1 Fix Execution Test for atan(NaN) and Fabs
1. Update expected value of atan(NaN) to NaN (#240)
2. Update spec for Fabs for denorm
2017-04-20 22:27:02 -07:00
Young Kim c50dd745d2 Add partial derivative test cases for pixel shaders (#220)
This change is to add another execution test case for partial derivative operations specific to pixel shaders.
The way we did this is by passing in the texture resource to the shader and taking the partial derivatives of these texture values.
Test is assuming the arithmetic precision of 1 ulp for derivative operations.

This change also has some changes on existing execution test
 - enable passing in Texture2D resource type as a default heap
 - reading primitive topology from XML file
 - clean up data driven tests: use DirectX Math structures and removing unused structures
2017-04-18 06:45:14 -07:00
Lei Zhang 9cab7fd909 Add doc for SPIR-V codegen (#215) 2017-04-14 18:18:21 -07:00
Young Kim e5265cc7ee Adding Execution Tests for ShaderOp Arithmetic operations (#207)
This change is to add execution tests for individual DXIL arithmetic operations.

Using TAEF's data-driven model to group operations by the type/number of operands for each instructions. (unary/binary operators for float/int/uint types)
Updating DXIL.rst for these instructions.
Update hctdb.py to enable internal links for DXIL instructions.
2017-04-12 00:14:00 -07:00
Xiang Li 843b64b320 Check exist function match dxil operation function when refresh operation fucntion cache. (#108) 2017-02-27 16:32:41 -08:00
Xiang Li cb0ba446c1 Fix validation bugs. (#10) 2017-02-07 22:18:10 -08:00
Tex Riddell 7beaa7ba54 Implement DXIL Container validation
- Implement and centralize container validation components in DxilValidation
- Strip RootSignature from module metadata before serializing to container
- Use existing DxilModule when serializing rather than constructing new one
- Add DxilModule::TryGetDxilModule for capturing diagnostics on metadata load
- Expose DxilPartWriters/DxilContainerWriter for use elsewhere (such as in validation)
2017-02-02 19:59:13 -08:00
Tex Riddell c18ed9133e Merge remote-tracking branch 'ms/dxil-v1.0' into integration 2017-02-01 15:43:43 -08:00
Tex Riddell 797548781c Integrate final opcode changes for DXIL v1.0
- Removes IAddc and ISubc
- Renames USubc to USubb
- Compacts opcodes
2017-02-01 15:22:29 -08:00
Xiang Li cf6f8beb4b Check Race Condition for TGSM (#48) 2017-01-30 16:09:31 -08:00
Tex Riddell 3bcc42ff10 Merge branch 'master' into dxil-v1.0 2017-01-27 17:18:24 -08:00
Tex Riddell af6b2a552f fixes #37 - License cleanup. 2017-01-27 16:48:08 -08:00
Tex Riddell 5e5897564a Merge branch 'master' into dxil-v1.0 2017-01-24 17:57:32 -08:00
David Peixotto f805233b49 Revert license text in banner comments to original llvm verbage (#33)
Fix #30: Revert license text in banner comments to original llvm verbage

This commit removes the Microsoft-specific copyright in llvm files
and reverts the copyright wording to the original llvm wording.

We used the following method to find the files to change:
1. Find all files in DirectXShaderCompiler that are also in llvm 3.7
2. For those files that have the Microsoft-specific copyright, revert
   it to the original llvm copyright as present in llvm 3.7
3. Revert the copyright in a few files that are not in llvm, but are
   mostly copies of files in llvm:
	lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
	lib\Transforms\Scalar\Reg2MemHLSL.cpp

Leave the Microsoft-specific copyright header in files not present
in stock llvm:

    include\dxc\*
    lib\HLSL\*
    lib\DxcSupport\*
    tools\clang\test\HLSL\*
    tools\clang\test\CodeGenHLSL\*
    tools\clang\unittests\HLSL\*
    tools\clang\unittests\HLSLHost\*
    tools\clang\tools\dxcompiler\*
    tools\clang\tools\dxa\*
    tools\clang\tools\dxc\*
    tools\clang\tools\dxopt\*
    tools\clang\tools\dxr\*
    tools\clang\tools\dxv\*
    tools\clang\tools\dotnetc\*
    utils\hct\*
    CONTRIBUTING.md
    COPYRIGHT
    LICENSE-MIT
    README.md
    cmake\modules\FindD3D12.cmake
    cmake\modules\FindDiaSDK.cmake
    cmake\modules\FindTAEF.cmake
    docs\DXIL.rst
    docs\HLSLChanges.rst
    docs\_themes\dxc-theme\layout.html
    docs\_themes\dxc-theme\theme.conf
    docs\_themes\dxc-theme\static\dxc-theme.css
    include\llvm\llvm_assert\assert.h
    include\llvm\llvm_assert\cassert
    include\llvm\Support\MSFileSystem.h
    include\llvm\Support\OacrIgnoreCond.h
    lib\MSSupport\CMakeLists.txt
    lib\MSSupport\MSFileSystemImpl.cpp
    lib\Support\assert.cpp
    lib\Support\MSFileSystemBasic.cpp
    lib\Support\Windows\MSFileSystem.inc.cpp
    lib\Transforms\Scalar\Reg2MemHLSL.cpp
    lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
    tools\clang\docs\UsingDxc.rst
    tools\clang\include\clang\AST\HlslTypes.h
    tools\clang\include\clang\Basic\BuiltinsDXIL.def
    tools\clang\include\clang\Basic\LangOptions.fixed.def
    tools\clang\include\clang\Parse\ParseHLSL.h
    tools\clang\include\clang\Sema\SemaHLSL.h
    tools\clang\lib\AST\ASTContextHLSL.cpp
    tools\clang\lib\AST\HlslTypes.cpp
    tools\clang\lib\CodeGen\CGHLSLMS.cpp
    tools\clang\lib\CodeGen\CGHLSLRuntime.cpp
    tools\clang\lib\CodeGen\CGHLSLRuntime.h
    tools\clang\lib\Frontend\Rewrite\FrontendActions_rewrite.cpp
    tools\clang\lib\Parse\HLSLRootSignature.cpp
    tools\clang\lib\Parse\HLSLRootSignature.h
    tools\clang\lib\Parse\ParseHLSL.cpp
    tools\clang\lib\Sema\gen_intrin_main_tables_15.h
    tools\clang\lib\Sema\SemaHLSL.cpp
    tools\clang\tools\d3dcomp\CMakeLists.txt
    tools\clang\tools\d3dcomp\d3dcomp.cpp
    tools\clang\tools\d3dcomp\d3dcomp.def
    tools\clang\tools\libclang\dxcisenseimpl.cpp
    tools\clang\tools\libclang\dxcisenseimpl.h
    tools\clang\tools\libclang\dxcrewriteunused.cpp
    tools\clang\tools\libclang\libclang.rc
    tools\dxexp\CMakeLists.txt
    tools\dxexp\dxexp.cpp
    tools\dxexp\LLVMBuild.txt
2017-01-24 17:54:00 -08:00
Xiang Li 664c0b6436 Change bool to i32 instead of i8. (#28) 2017-01-23 17:54:09 -08:00
Tex Riddell 220f78a557 Merge 'master' into dxil-v1.0 2017-01-20 14:11:27 -08:00
Xiang Li 5623234187 Strip function parameter for entry and patch constant function. (#20)
Strip function parameter for entry and patch constant function

* Update error message for ValidationTest::MultiDimArray

* Merge remote-tracking branch 'origin/master'

# Conflicts:
#	lib/HLSL/DxilValidation.cpp
#	tools/clang/unittests/HLSL/ValidationTest.cpp

* Update error message for ValidationTest::MultiDimArray

Update error message for ValidationTest::MultiDimArray

* Fix merge error. (#3)

* Delete local file (#4)

* Fix merge error.

* Delete local file

* Strip function parameter for entry and patch constant function. (#5)
2017-01-19 19:00:17 -08:00
Tex Riddell 4b532ceff9 Merge branch 'master' into integration 2017-01-18 19:43:07 -08:00
Tex Riddell 69d8d3209b Integrate change to DXIL Version 1.0 2017-01-18 19:18:55 -08:00
Tex Riddell 55ba393c2c Signature packing, codegen fixes, and validation fixes and additions.
- Add DxilSignatureAllocator for signature packing
  - Fix signature validation.  Add more validation.
  - Fix and add validation tests.
  - Fix codegen for inout params with SV like SV_Coverage
  - fix m_SemanticStartIndex on DxilSignatureElement::Initialize
  - fix DxilSignatureElement::GetColsAsMask for start col == 2
  - Add diags for signature allocation failures
  - Use Regex in ValidationTest
2017-01-17 18:10:16 -08:00
Xiang Li ee0e81b047 Disable multi-dim array type and function call. (#12) 2017-01-17 13:30:42 -08:00
Xiang Li 96c0eb50ef Cleanup more Validation TODOs. 2017-01-12 17:59:37 -08:00
Xiang Li 03149de76f Cleanup more validation TODOs. 2017-01-11 10:42:48 -08:00
Xiang Li 8eb801f1fd Clean more validation TODOs. 2017-01-10 16:24:10 -08:00
Xiang Li 245a771a85 1. Clean more validation TODOs.
2. Support array of SV_Target.
2017-01-10 11:44:48 -08:00
Xiang Li 28b3ffe821 Clean more validation TODOs. 2017-01-04 13:29:28 -08:00
Marcelo Lopez Ruiz 6ee4074a4b first commit 2016-12-28 11:52:27 -08:00