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

761 Коммитов

Автор SHA1 Сообщение Дата
Ehsan b0713a6b50
[spirv] Handle Sparse Images in GatherRGBA (#872) 2017-12-04 14:47:54 -05:00
Lei Zhang d0b7c89d87
[spirv] Let .Consume() return access chains (#873)
This will allow further indexing into the struct used to
parameterize ConsumeStructuredBuffer.
2017-12-04 12:50:11 -05:00
Lei Zhang fb377afe5a
[spirv] Add missing capability for storage image read/write (#870)
Refreshed SPIRV-Tools and re-enabled all validations for texure/
buffer methods.

Also added support for -Cc to color the disassembly.
2017-12-01 17:28:56 -05:00
Ehsan 43e5436524
Increased MaxIncludeFiles limit & filed issue #866 (#867) 2017-12-01 14:01:33 -05:00
Lei Zhang 2624406a58
[spirv] Fix OpImageRead return type (#868)
OpImageRead should return a 4-component vector.
2017-12-01 13:09:09 -05:00
Lei Zhang b1bad83b22
[spirv] Support option to output byte offset in disassembly (#869) 2017-12-01 13:08:50 -05:00
Lei Zhang f2144778b3
[spirv] Fix structurued buffer indexing in Interlocked*() (#864) 2017-11-30 10:13:39 -05:00
Lei Zhang 7f6aaf6cc6
[spirv] Use OpStore instead of OpVariable initializer (#858)
Right now certain optimization passes in SPIRV-Tools ignores
OpVariable initializer:

https://github.com/KhronosGroup/SPIRV-Tools/issues/1017

As a workaround, this commit replaces OpVariable initializer with
OpStore.

This commit should be reverted once OpVariable initializer is
supported.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/853
2017-11-29 10:53:34 -05:00
Ehsan 4c77d6a2e5
[spirv] Don't silently ignore unknown decls in TU. (#857) 2017-11-28 13:42:48 -05:00
Ehsan 1d92f9a129
[spirv] Handle RecordDecls defined inside DeclStmt (#855) 2017-11-27 16:50:15 -05:00
Lei Zhang 3a4c0338a4
[spirv] Add validation for vk::builtin usage (#854) 2017-11-27 16:12:39 -05:00
Ehsan fcde415c18
[spirv] Handle literal int and 64-bit int. (#851)
Also update the FlatConversion code to handle float and boolean
initializers.
2017-11-27 14:40:20 -05:00
Lei Zhang 6a6290f2ed
[spirv] Add support for casting from float4 to float2x2 (#849) 2017-11-27 10:25: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
Marcelo Lopez Ruiz 3c729a038d
Container clipboard and XML serialization (#848)
* Add a tab for compilation options
* Add support to copy/view containers, and to paste them into shader ops.
2017-11-24 18:03:05 -08:00
Lei Zhang 04a5269451
[spirv] Support function foward declaration (#847) 2017-11-24 15:52:47 -05:00
Xiang Li fa0674829b
Fix crash in code gen caused by cast atomic dst address. (#843) 2017-11-24 00:55:00 -08:00
Lei Zhang 05057495e8
[spirv] Adopt new changes in SPIRV-Tools (#846)
Uses the legalization pass recipe from SPIRV-Tools.

Also change -fcgl to disable both legalization and optimization.

Validation on some tests are turned off because of new image
instruction checking in SPIRV-Tools. Enabling them is a TODO.
2017-11-23 22:30:49 -05:00
Ehsan 8d072dc9ad
[spirv] Fix potential Release build issues (#845) 2017-11-23 16:54:52 -05:00
Ehsan 31855e75a8
[spirv] Convert floats of different bit widths (#844)
Also support 'literal float' to 'float' conversion.
2017-11-23 16:54:37 -05:00
Lei Zhang 1d671e843e
[spirv] Support static member with inline initializer (#842) 2017-11-22 19:52:49 -05:00
Ehsan 998bab9dea
[spirv] Translate intrinsic msad4 function. (#808) 2017-11-22 18:36:59 -05: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
Lei Zhang ae9635c56c
[spirv] Use .getAs<>() instead of cast<>() for RecordType (#841)
cast<RecordType>(T.getTypePtr()) cannot handle cases in which
T is typedef of some struct type.
2017-11-22 17:57:05 -05:00
Ehsan 84abf7d86c
Constant evaluation for HLSLVectorElementExpr (#840) 2017-11-22 17:52:53 -05:00
Lei Zhang ac8618ab07
[spirv] Update SPIRV-Tools and mark resource write legalization (#839) 2017-11-22 13:59:27 -05:00
Lei Zhang 8d052c88f4
[spirv] Add support for semantics on structs (#831)
All fields will inherit the semantic attached to the struct, with
index increasing sequentially.
2017-11-21 10:26:17 -05:00
Xiang Li f9434c0c3f
Add textbox for entry, target, option. (#830)
* Add textbox for entry, target, option.

* Merge new ui with HlslFileVariables.
2017-11-20 21:50:52 -08:00
Young Kim 8ba7f5a200
Clean up for versions (#829)
-bump up dll version for fixed version
-show dxcompiler and dxil version number for dxc help message
-emit warnings for dxcompiler validator that container will not be signed
2017-11-20 11:09:28 -08:00
Ehsan 3809395c08
[spirv] Support CXXDefaultArgExpr translation. (#825) 2017-11-20 08:46:07 -05:00
Ehsan 06aadc4789
[spirv] CheckAccessFullyMapped unsupported error (#824) 2017-11-20 08:45:43 -05:00
Xiang Li e9f0425202
Use neg+imax for iabs. (#828) 2017-11-18 00:18:31 -08:00
Lei Zhang 4ed18e7be3
[spirv] Write values of resource types as a whole (#826)
Right now we just do a load and then a store over of whole struct,
completely ignoring the storage class (and thus layout). This is
surely invalid SPIR-V, but we need this right now to enable some
workloads. Hopefully SPIRV-Tools will be able to remove these
loads/stores.

Updating associated counters for certain types is a TODO.
2017-11-17 17:50:00 -05:00
Lei Zhang cc61d9d294
[spirv] Allow samplers and textures in initializer list (#815)
They are treated as primitive types and handled as a whole.
2017-11-17 14:53:52 -05:00
Xiang Li 259d6624e6
Don't generate lshr for cb array indexing. (#812) 2017-11-17 10:54:05 -08:00
Lei Zhang 0b309e9faf
[spirv] Add CL option to disable SPIR-V legalization (#814)
/fcgl is reused in SPIR-V CodeGen for disabling SPIR-V legalization.
2017-11-17 11:44:44 -05:00
Lei Zhang 0d150879fa
[spirv] Use SpirvEvalInfo to convey lvalue/rvalue (#822)
Previously we reply on Expr::isGLValue() to check whether an
expression is lvalue. That requires lots of ad-hoc fixes in
the CodeGen for missing/wrong lvalue/rvalue.

Now we use SpirvEvalInfo to calculate the lvalueness together
with the <result-id>. It is much cleaner.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/819
2017-11-17 11:31:52 -05:00
Lei Zhang aa7c2bc402
[spirv] Fix missing return value cases (#809)
If there are no return value specified in the source code for a
certain control flow path, just return the null value.

Previously always use OpReturn to terminate basic blocks without
explict return statement from the source code, which may cause
illegal SPIR-V generated.
2017-11-17 09:31:23 -05:00
Lei Zhang 406fe38220
Add validation checks for HS/GS attributes after parsing (#768)
This commit add checking for three HS/GS rules:

* HS entry point should have the patchconstantfunc attribute
* GS entry point should have the maxvertexcount attribute
* GS stream-output objects should be inout parameters
2017-11-16 18:44:27 -05:00
Ehsan 9772bf6c5a
[spirv] Fix location mismatches between HS and DS (#821)
Uses location assignments in alphabetical order for HS outputs and DS
inputs. This will make the interface matching for these two stages
robust.
2017-11-16 18:20:24 -05:00
Tex Riddell 8cf7292bee
Fix IsTypeNumeric hang with incomplete array (#760)
* Fix IsTypeNumeric hang with incomplete array
* Fix IsTypeNumeric for empty nested struct.
2017-11-16 11:40:51 -08:00
Young Kim 289d09e700
Bitcast for 16bit types (#817)
This change adds bitcast intrinsics for 16bit types (asfloat16, asint, asuint)
2017-11-16 11:38:56 -08:00
Lei Zhang 6e874ab3fe
[spirv] Turn SpirvEvalInfo into a class (#820)
Cleaned up methods on SpirvEvalInfo. Also added a new field or
lvalue/rvalue, which will be used later.
2017-11-16 14:25:00 -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 ddf64b3258
[spirv] Emit warnings for the same binding number (#816)
This is to enable certain workflows that reflection is used to
change the binding numbers after codegen.
2017-11-16 12:13:41 -05:00
Ehsan 511ef092a9
[spirv] Handle inout structs. Fixed issue #806. (#810) 2017-11-16 11:25:00 -05:00
Lei Zhang dc0babf2ff
[spirv] Validate vk::push_constant usage (#807)
Attaching vk::push_constant and vk::binding to the same global
variable is disallowed.
2017-11-16 08:57:23 -05:00
Young Kim 3cad152a90
Template argument for byteaddressbuffer load store (#804)
This change removes new Load variations (LoadHalf, LoadFloat, etc) for RWByteAddressBuffer/ByteAddressBuffer methods and add templated Load intrinsics. This templated Load only works on scalar or vector types, and its variations (Load2, Load3, Load4, etc) do not work with templates and work as it did before (only storing uints). For Store operation, you can store any scalar or vector types of up to 16 bytes, while prior to 2018 Store only supported storing uint scalar.
2017-11-15 18:47:12 -08:00
Lei Zhang 21f16a1eaf
[spirv] Emit note for the intial use location of bindings (#811)
This makes it easier for the devs to see with which a binding
numbers is conflicting.
2017-11-15 18:36:04 -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
Xiang Li 0dbba98152
Remove check on empty struct when LoadDxilStructAnnotation. (#798) 2017-11-14 10:34:01 -08: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
Young Kim a48d81fcac
New scalar types (#792)
This change is to add fixed width scalar types in HLSL 2018.
These types are: int16_t, uint16_t, int32_t, uint32_t, float16_t, float32_t, and float64_t.
Prior HLSL versions do not support these fixed width types.

This change also renames /no-min-precision command line option to /enable-16bit-types. int16_t and uint16_t are only allowed with this mode.
2017-11-13 15:03:19 -08: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 df7fcb5469
[spirv] Emit warnings for cbuffer/tbuffer member initializers (#794)
Also modified the testing infrastructure to support checking
warning messages.
2017-11-13 12:51:58 -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 909351314c
[spirv] Use Workgroup storage class for groupshared variables (#788) 2017-11-10 16:49:34 -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
Ehsan 2b4c488091
[spirv] Test case for empty struct stage variables (#777) 2017-11-09 10:53:34 -08:00
Young Kim 44db464c32
Native Int16 and Uint16 types (#783)
This change is to introduce native precision types for shader model 6.2. With native half (float16) types, we will introduce native int16/uint16 types with same command line option. This means that one option will disable all min precision types. For now, int16/uint16 types will be exposed on HLSL level as int16_t and uint16_t.

This change also includes some constant buffer fixes for 16 bit types, as well as int64 types.
2017-11-09 10:03:27 -08:00
Ehsan 56b1f9628e
[spirv] Add location to error messages and unify. (#776) 2017-11-09 08:35:43 -08:00
Lei Zhang 3caadf5001
[spirv] Update external dependencies (#779) 2017-11-09 10:26:33 -05:00
Ehsan d756ff5094
[spirv] Handle alignment & offset of empty structs (#774) 2017-11-08 11:31:22 -08: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
John Porto 6a25d56df2
Modifies CodeGenSimpleHS 10 and 11 so that they use target hs_6_0 (#766) 2017-11-07 15:13:04 -08:00
Ehsan 7cb1c20853
[spirv] Handle TessFactor size mismatches. (#771) 2017-11-07 12:37:02 -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 5759c22d82
[spirv] Add check for Patch decoration in interface tests (#770)
Also make parameter names clear that they are for patch constant
function (PCF), not generally patch constant, which also involves
some domain shader inputs.
2017-11-07 14:30:29 -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
Jeff Noyle 966eb72fc4
Emit all the args (#765) 2017-11-06 16:25:36 -08:00
John Porto 502323cb73
moves the patch constant fn validation to the backend. (#754)
* moves the patch constant fn validation to the backend.

* addresses comments

* fixes broken test
2017-11-06 12:41: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
Tex Riddell 694296b6b0
Add target-dependent experimental function attribute (#759) 2017-11-02 19:20:57 -07:00
Lei Zhang 6f9fb6a534
[spirv] Remove duplicated HLSL type probing methods (#755) 2017-11-02 12:32:48 -04:00
Lei Zhang 2a15ef6914
[spirv] Fix effcee error message check name and file name (#756) 2017-11-02 12:30:08 -04:00
Ehsan 529f6ee6bf
[spirv] Translate FlatConversion implicit cast. (#750) 2017-11-01 09:29:09 -07:00
Ehsan 317eba1b86
[spirv] Emit error for tex*() intrinsic functions. (#738) 2017-11-01 06:19:21 -07:00
Xiang Li adcdb2ccba
Use _wcsicmp instead of wcsicmp. (#752) 2017-10-31 18:09:39 -07:00
Jeff Noyle 0acdbd9a8c
PIX pixel-cost visualizer: Fix byte offset, simplify ReEmitDxilResources (#749)
* byte offset, not element offset => multiply by sizeof(dword)
set uav to r/w
Re-emit meta-data becomes delete then emit

* update test

* re-compute view id state
2017-10-31 13:37:07 -07:00
John Porto 3563ae9c5a
Allows Patch Constant Function definition after HS entry point (#748)
* Allows Patch Constant Function definition after HS entry point

* Fixes SimpleHS8.hlsl
2017-10-31 10:39:56 -07:00
Ehsan c5dc49a7fd
[spirv] Translate intrinsic Lit function. (#744) 2017-10-31 10:14:56 -04:00
Xiang Li b304e729a2
Use LHS type as result type for compound assignment. (#746) 2017-10-30 17:37:59 -07:00
Xiang Li 8c790a8b0e
Do not generate phi of pointers. (#745)
* Disable optimizations which may generate phi of pointers.
2017-10-30 15:53:25 -07:00
Xiang Li cb2a7e46d8
Only set fastmath on binary math op. (#743) 2017-10-30 13:18:32 -07:00
Young Kim ce9d6267a5 DataLayout String and ConstantBuffer Offset Fix (#727)
This change is to update correct target data layout for DXIL. Now that we have a scalar type of size less than dwords, we need to correctly print string data layout to determine non-packed structure layout.

This change also fixes alignments issues with ConstantBuffer as it was having different CG path from cbuffer.
2017-10-26 14:51:50 -07:00
Ehsan 3ff562f294 [spirv] Tests InputPatch & OutputPatch operator[] (#737) 2017-10-26 16:24:03 -04:00
Ehsan 6d8bf3e34a [spirv] Support GS output stream types. (#736) 2017-10-26 14:02:40 -04:00
Lei Zhang 4046ce318a [spirv] Update dependencies and use two new opt passes (#735) 2017-10-25 16:43:54 -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 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
Xiang Li ef7a891ab2 Support case write to struct input. (#731) 2017-10-23 19:09:30 -07:00
Ehsan be61057cb5 [spirv] Translation of domain shaders. (#724)
Added necessary functionality to handle domain shader translation.
Also added Bezier domain shader as test.
Also added Patch decoration to the hull shader patch constant outputs and
the domain shader patch constant inputs.
2017-10-23 15:47:13 -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
Adam Yang 946e0b3922 Merge pull request #726 from adam-yang/test
Using IMalloc::Free instead of delete for Release.
2017-10-23 11:26:39 -07:00
Marcelo Lopez Ruiz b7ce331dee Fix unused var warning in Release, fix #709 misplaces parens (#728) 2017-10-21 14:43:23 -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
Adam Yang 655b1fc8dd Initializing malloc obj in DxcDiaSourceFile 2017-10-20 17:00:41 -07:00
Young Kim 40369a5884 Structure alignment Change (#721)
Structure buffer alignment change for float16. Starting in shader model 6.2, the structure will match that of #pragma pack(8) alignment in C++

Removing padding for structure buffer. We will not have any padding in HLSL structure since load/store operation already handles offset as if padding exist in #pragma pack(8) mode in C++

Disable legacy alignment for non precision mode as it was only needed for min precision
2017-10-20 13:51:42 -07:00
Ehsan a62dba918f [spirv] Translate intrinsic Interlocked* methods. (#722) 2017-10-20 13:06:37 -04:00
Jeff Noyle 5b3f3d7c16 Another instance of parameters-that-should-have-been-undef (#718) 2017-10-18 09:07:52 -07:00
Xiang Li a7cba6d180 Create constant initilizer from static constructor if possible. (#717)
* Create constant initilizer from static constructor if possible.
2017-10-17 18:17:00 -07:00
Jeff Noyle 9cb2d14005 Specify undefined values for unused arguments... (#716) 2017-10-17 14:41:40 -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
Lei Zhang 2b4a131e6d [spirv] Fix returning from non-Function storage class (#712)
If we are returning some struct value not in the Function storage
class, we need to decompose it and write each component to the
corresponding component of a temporary variable and then return
that temporary variable.

Also fixed a crash regarding implicitly generated constructors
and destructors for structs.
2017-10-16 14:33:49 -04:00
Ehsan 0888e319e7 [spirv] Intrinsic fwidth & faceforward (#711) 2017-10-16 13:53:08 -04:00
Lei Zhang dac585ffb1 [spirv] Refactoring: renaming test files to keep consistency (#710) 2017-10-16 10:48:01 -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
Young Kim 85409901ff Update version to 2017 10 (#703)
Updating dxcompiler file version and llvm.ident version to 2017 10 for new release.
2017-10-13 10:45:08 -07:00
Lei Zhang 2e1ea68d6c [spirv] Add support for texture .GatherCmpRed() method (#700) 2017-10-13 11:21:38 -04:00
Lei Zhang 2419dbba86 [spirv] Stop if errors happen during translating Decls (#701)
This prevents us from calling legalization/optimization passes
on invalid SPIR-V binary code.
2017-10-13 11:21:26 -04:00
Ehsan e508374632 [spirv] Support Hull shader translation (#692) 2017-10-12 18:26:59 -04:00
Xiang Li 9de00de3b4 Skip function type inside initilizer. 2017-10-12 13:48:13 -07:00
Xiang Li f4b45da70c Check embedded typos for CXXUnresolvedConstructExpr. 2017-10-12 13:48:13 -07: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
Xiang Li 2bc91c6f07 Skip half when Eval builtins. 2017-10-11 23:41:27 -07:00
Xiang Li 7f9ee1a8f6 Add test for minprec on intrinsic. 2017-10-11 23:41:27 -07:00
Xiang Li 9f168a8b30 Code cleanup. 2017-10-11 23:41:27 -07:00
Xiang Li 6b7871a243 Coorect delayed typos for Ternay operator. 2017-10-11 23:41:27 -07:00
Marcelo Lopez Ruiz 64f3b34995 Adds support for pipeline restart (#683)
* Adds support for pause/resume in pipeline.
* Adds 0.0 as the validator version to indicate no validation should occur.
* Moves module parsing from dxcompiler down to HLSL library.
* Adds support for optimizer to process a DXIL part.
* Adds a form with designer support for the interactive optimizer.
2017-10-11 14:04:24 -07:00
Xiang Li e26728ba5f Use float for tex coord instead of float_like. (#688)
* Use float for tex coord instead of float_like.

* Support min prec for GetDim.
2017-10-10 18:53:50 -07:00
Lei Zhang ea9f8cfbaf [spirv] Refactoring: create dedicated functions for method calls (#687) 2017-10-10 21:39:49 -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
Xiang Li 7b8237040d Refine test. 2017-10-10 10:51:37 -07:00
Xiang Li bdcaa4caa0 Always use public for hlsl. 2017-10-10 10:51:37 -07:00
Jeff Noyle b06a8153ff Shader debug instrumentation (#680)
See the comment in DxilDebugInstrumentation.cpp for a summary of how this-all works. Basically: instrument all instructions to output "trace" info to a UAV so that a debugger can reconstruct the execution of the shader and offer a debugger-like experience.
2017-10-09 15:30:29 -07:00
Young Kim 32af2dad66 Fix static data member const issue. (#668)
Fix static data member const issue. For now we are setting static data member to have internal linkage simply because current module passes does not remove global variable for static data member unless it's an internal linkage (LowerStaticGlobalIntoAlloca), and we do not allow instructions using global variables. This can be fixed in the future if we want to keep static data member to maintain external linkage and create an extra pass to handle this.
2017-10-09 11:48:27 -07:00
Lei Zhang aeeaa68b93 [spirv] Add interpolation tests on non-struct parameters (#681) 2017-10-06 10:00:56 -04:00
Lei Zhang 102fe247f1 [spirv] Support RWByteAddressBuffer atomic methods (#678) 2017-10-06 09:59:13 -04:00
Lei Zhang cd5299e946 [spirv] Add support explicit binding for CTBuffer (#672)
This commit adds support for explicit binding assignment in
cbuffer/tbuffer/ConstantBuffer/TextureBuffer.
2017-10-03 11:25:51 -07: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
Ehsan 67f14ca00e [spirv] Load() for Texture2DMS & Texture2DMSArray. (#670) 2017-10-02 16:57:27 -04:00
Ehsan 94e7918c01 [spirv] Add test for class method calls. (#671) 2017-10-02 15:36:06 -04:00
Lei Zhang a5afc66352 [spirv] Remove write tests to read-only Buffer<T> (#667) 2017-09-29 19:28:14 -04:00
Xiang Li 36b2a12695 Fix row index for array of matrix input/output. (#660)
* Fix row index for array of matrix input/output.
Also remove sret when flatten functions.
2017-09-28 17:23:57 -07:00
Ehsan 58612be9f3 [spirv] More compute shader semantics. (#662)
* SV_GroupID
* SV_GroupIndex
* SV_GroupThreadID
2017-09-28 17:43:18 -04:00
Lei Zhang 04e269a0e3 [spirv] Change SPIRVEmitter methods to return structs (#659)
This allows us to convey more information about the evaluation
(constness, storage class, layout rule, etc.) than before
(only result id).

This sets the foundation for propagating relaxed precision info
later.
2017-09-28 14:56:12 -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
Lei Zhang 62629d982a [spirv] Call SPIR-V legalization passes from SPIRV-Tools (#655)
When seeing opaque types within structs in function parameter,
function return, and variable definition, invoke SPIRV-Tools
legalization passes.

Also refreshed external projects
2017-09-27 16:04:35 -04:00
Ehsan 52c27ffbbd [spirv] CalculateLevelOfDetail for Texture types. (#653) 2017-09-27 14:15:32 -04:00
Young Kim 5368b6eea8 Add Basic Triangle Half Test (#656)
This test is mainly to test that half types in function signature works as expected. Not enabled by default yet.
2017-09-27 10:25:31 -07:00
Young Kim 028a08a6a9 Code Cleanup for syncing with Windows (#651) 2017-09-26 09:45:43 -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
Xiang Li 58b7f88864 Use correct channel for gather with offset. (#648) 2017-09-25 17:43:24 -07:00
Jeff Noyle f169e6f238 PIX pixel-hit instrumentation: Re-emit type system, fix several issues with the UAV (#635)
* Add SV_Position index parameter, various minor tweaks to UAV setup

* Convert to raw buffer

* fix up unit tests, add a few names to variables

* CR feedback: check for pre-existing type; typo
2017-09-25 15:22:05 -07:00
Lei Zhang 5f2b598050 [spirv] Support static struct member functions (#640)
These functions are just translated into standalone functions
through the normal translation path.
2017-09-25 09:23:43 -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
Ehsan e69398519d [spirv] Translation for Comma operator. (#638) 2017-09-22 13:04:54 -07:00
Xiang Li 1887a45885 Print error message when link fail. (#633)
* Print error message when link fail.
Also add -h for dxl.
2017-09-22 06:20:14 -07:00
Ehsan 82463dd3d1 [spirv] Test for returning a struct from function. (#637) 2017-09-21 09:33:40 -07:00
Lei Zhang ed8aa07197 [spirv] Support struct member functions (#629)
Member functions are translated into SPIR-V standalone functions
with an additional first parameter for the struct type.
2017-09-21 09:32:01 -07:00
Lei Zhang 88cca461de [spirv] Stop translation if there are errors in previous stages (#632) 2017-09-20 20:27:50 -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
Ehsan de7ce30149 [spirv] Texture operator[], .mips[][], .sample[][] (#625)
* [spirv] Texture operator[], .mips[][], .sample[][]

* Address comments.
2017-09-20 20:25:24 -07:00
Xiang Li 6b3fefb5e4 Support matrix for frexp. (#624) 2017-09-19 08:56:25 -07:00
Ehsan 76a835bbd1 [spirv] Access and assigment for RWTexture types. (#622) 2017-09-19 08:47:41 -07:00
Marcelo Lopez Ruiz 6bd218d06d Adds support for pasting opt pipeline, improve highlight of %n tokens (#619) 2017-09-13 14:21:00 -07:00
Young Kim 9fb9c33b0f Initial implementation for cBuffer test for float16. (#616)
Since this feature is planned to be supported in future release, the test will fail on current OS versions.
This test case should be tested once there is a driver support for float16 option.
2017-09-12 16:53:57 -07:00
mrvux 61f4919ef1 Dotnet types public (#617)
Make dia types public in dndxc
Make dxc types public
Add IDxcLinker interface
2017-09-12 16:28:36 -07:00
Young Kim fb33d62978 Restrict no min precision option to shader model 6.2 (#615) 2017-09-12 16:05:08 -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
Young Kim 1590f7e953 Execution Test: Wave Intrinsics Caps check (#613) 2017-09-05 16:16:29 -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
Lei Zhang 5eaf13b879 [spirv] Support {Append|Consume}StructuredBuffer (#608)
* [spirv] Support {Append|Consume}StructuredBuffer

* Supported the {Append|Consume}StructureBuffer type
* Supported .Append() and .Consume()

{Append|Consume}StructureBuffer<S> is implemented as OpTypeStruct
with an OpTypeRuntimeArray of S. And each such array will have
an associated counter, whose type is OpTypeStruct of 32-bit integer.
The index for .Append()/.Conume() is fetched by doing atomic
operations on the associated counter.

* Use subtraction of one instead of addition of negative one
2017-08-31 16:09:45 -07:00
Xiang Li ceb0c7aee7 Allocate correct size for idxList in TranslateStructBufMatSubscript. 2017-08-30 12:00:28 -07:00
Lei Zhang 13adee8411 [spirv] Support output disassembly in dxc (#603)
* [spirv] Support output disassembly in dxc

* Use normal pointers in DisassembleSpirv() and add tests

* keep script_dir under setlocal
2017-08-30 08:53:29 -07:00
Lei Zhang f4e379db85 [spirv] Support assigning to objects of composite types (#598)
For these objects, if the lhs and rhs are of different storage
class, we may need to do the assignment recursively at the
non-composite level since OpStore requires that the pointer's
type operand must be the same as the type of object.
2017-08-30 08:52:54 -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
Marcelo Lopez Ruiz 6322c8ca3f Fix #604 by handling scalar functional inits in ICE and evaluation (#605) 2017-08-29 14:56:40 -07:00
Young Kim c110357e99 fix sign unsign comparison for wave intrinsics test (#601) 2017-08-29 10:32:57 -07:00
Ehsan f3d5010b2e [spirv] Refactor Buffer and Texture load functions (#600)
[spirv] Refactor Buffer and Texture load functions

Also fixes 2 bugs:

1- RWBuffer must use OpImageRead rather than OpImageFetch.
2- OpImageFetch/Read take a parameter whose type is an image. We were
incorectly passing the *variable* (which is of type pointer-to-image).

This change also allows TextureXX<type> to be used with types other than
float4. Tests were added for such cases.
2017-08-28 14:35:40 -07:00
Lei Zhang 10a4a84f68 [spirv] Avoid generating duplicated debug names for images (#597) 2017-08-25 15:28:38 -07:00
Ehsan 59d36fefc0 [spirv] Support writing to RWBuffers. (#594) 2017-08-24 20:36:27 -07:00
Lei Zhang 92a73a28c5 [spirv] Add support for (RW)StructuredBuffer (#593)
* Supported (RW)StructuredBuffer types
* Supported accessing elements in (RW)StructuredBuffer
* Supported the Load() method
* Supported std430 layout

Also optimized OpAccessChain CodeGen. This is necessary right
now because otherwise we will have pointers to intermediate
composite objects like structs and arrays. Structs/arrays are
different types with and without layout decorations. To have the
correct struct/array pointer type for OpAccessChain, we need to
always pass in the correct layout rules when translating the
types, which is not easy. Optimizing intermediate OpAccessChain
away solves the problem because scalar/vector/matrix types are
unique given the same parameter.
2017-08-24 20:36:07 -07:00
Young Kim bdd7c63873 Skip validator <1.2 for half tests (#595) 2017-08-24 14:11:45 -07:00
Lei Zhang 516f3270c8 [spirv] Add support for ConstantBuffer (#590)
Also optimized codgen for consecutive array/struct indexing
expressions to avoid generating multiple OpAccesChains.
2017-08-23 21:52:27 -07:00
Ehsan 2b5f9ffe1d [spirv] Buffer/RWbuffer Load() and operator[] (#589)
* [spirv] Support Load function for Buffer/RWBuffer.

* [spirv] Operator[] for Buffer/RWBuffer.

Also some improvement for handling of vec2 and vec3 cases:
use OpVectorShuffle instead of OpCompositeExtract&OpCompositeConstruct.

* Address code review comments.
2017-08-23 21:51:53 -07:00
Ehsan 6b09a407bb [spirv] Support translation of Buffer & RWBuffer (#588) 2017-08-23 09:15:11 -07:00
Ehsan a4efd3babc [spirv] Add test for passthrough compute shader. (#587)
Using raw buffers (ByteAddressBuffer and RWByteAddressBuffer).
2017-08-22 22:24:19 -07:00
Lei Zhang 8bb01b2dac [spirv] Support cbuffer and layout decorations (#585)
* Added support for the cbuffer type
* Added support for accessing elements in cbuffer
* Added support for std140 layout rules
2017-08-22 22:23:36 -07:00
Young Kim c551a1acac Fix wave intrinsic prefix test to not assume that lane id is in same order as thread id (#586) 2017-08-22 15:24:46 -07:00
Young Kim b89c21d25b Fp16 constant buffer and shader flag (#575)
This change is to support fp16 on constant buffer.
We are still keeping a row pitch of 4 dwords. So we can fit up to 8 halfs in one row.
Dword data types will be aligned to dword address space for efficiency. We are also introducing new flags "use native low precision" if we have low precision type present and /no-min-precision option is enabled.
2017-08-21 15:06:45 -07:00
Ehsan f17bbb3c39 [spirv] Translation of SV_DispatchThreadID. (#582) 2017-08-21 08:43:56 -07:00
Ehsan 4cbc45cf27 [spirv] Support (RW)ByteAddrressBuffer and load/store methods (#581) 2017-08-21 08:43:37 -07:00
Ehsan 1e6a9afd47 [spirv] Translate numthreads attribute for CS. (#580) 2017-08-21 08:43:06 -07:00