├── Dockerfile ├── LICENSE ├── Makefile └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 as dxc_builder 2 | RUN apt-get update && \ 3 | apt-get install -y \ 4 | software-properties-common \ 5 | build-essential \ 6 | git \ 7 | cmake \ 8 | ninja-build \ 9 | python 10 | 11 | ENV DXC_BRANCH=master 12 | ENV DXC_REPO=https://github.com/Microsoft/DirectXShaderCompiler.git 13 | ENV DXC_COMMIT=d75f96aabb27af63c5dc05cad4c47f7de85ca349 14 | 15 | WORKDIR /dxc 16 | 17 | RUN mkdir -p /dxc && \ 18 | git clone --recurse-submodules -b ${DXC_BRANCH} ${DXC_REPO} /dxc && \ 19 | git checkout ${DXC_COMMIT} && \ 20 | git reset --hard 21 | 22 | RUN mkdir -p /dxc/build && cd /dxc/build && \ 23 | cmake ../ -GNinja -DCMAKE_BUILD_TYPE=Release $(cat ../utils/cmake-predefined-config-params) && \ 24 | ninja 25 | 26 | ENTRYPOINT ["/dxc/build/bin/dxc"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Graham Wihlidal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NS = gwihlidal 2 | VERSION ?= latest 3 | 4 | REPO = dxc 5 | NAME = dxc 6 | INSTANCE = default 7 | 8 | .PHONY: build push shell run start stop rm release 9 | 10 | build: 11 | docker build -t $(NS)/$(REPO):$(VERSION) . 12 | 13 | push: build 14 | docker push $(NS)/$(REPO):$(VERSION) 15 | 16 | shell: build 17 | docker run --rm --name $(NAME)-$(INSTANCE) --entrypoint=/bin/sh -i -t $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION) 18 | 19 | run: build 20 | docker run --rm --name $(NAME)-$(INSTANCE) $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION) 21 | 22 | start: build 23 | docker run -d --name $(NAME)-$(INSTANCE) $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION) 24 | 25 | release: build 26 | make push -e VERSION=$(VERSION) 27 | 28 | stop: 29 | docker stop $(NAME)-$(INSTANCE) 30 | 31 | rm: 32 | docker rm $(NAME)-$(INSTANCE) 33 | 34 | default: build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-dxc 2 | Docker image with Microsoft DirectX shader compiler 3 | 4 | Hub: https://hub.docker.com/r/gwihlidal/dxc/ 5 | 6 | ## Usage 7 | ``` 8 | $ docker run --rm gwihlidal/dxc -help 9 | ``` 10 | 11 | ``` 12 | $ docker run --rm -v $(pwd):$(pwd) -w $(pwd) gwihlidal/dxc -T -E 13 | ``` 14 | 15 | ## Example Output 16 | 17 | ``` 18 | $ docker run --rm -v h:/Repositories/docker-dxc:/tests -w /tests gwihlidal/dxc -T cs_6_0 -E main test.hlsl 19 | warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments. 20 | 21 | ; 22 | ; Input signature: 23 | ; 24 | ; Name Index Mask Register SysValue Format Used 25 | ; -------------------- ----- ------ -------- -------- ------- ------ 26 | ; no parameters 27 | ; 28 | ; Output signature: 29 | ; 30 | ; Name Index Mask Register SysValue Format Used 31 | ; -------------------- ----- ------ -------- -------- ------- ------ 32 | ; no parameters 33 | ; 34 | ; Pipeline Runtime Information: 35 | ; 36 | ; 37 | ; 38 | ; Buffer Definitions: 39 | ; 40 | ; Resource bind info for Buffer0 41 | ; { 42 | ; 43 | ; struct struct.Pixel 44 | ; { 45 | ; 46 | ; int colour; ; Offset: 0 47 | ; 48 | ; } $Element; ; Offset: 0 Size: 4 49 | ; 50 | ; } 51 | ; 52 | ; Resource bind info for BufferOut 53 | ; { 54 | ; 55 | ; struct struct.Pixel 56 | ; { 57 | ; 58 | ; int colour; ; Offset: 0 59 | ; 60 | ; } $Element; ; Offset: 0 Size: 4 61 | ; 62 | ; } 63 | ; 64 | ; 65 | ; Resource Bindings: 66 | ; 67 | ; Name Type Format Dim ID HLSL Bind Count 68 | ; ------------------------------ ---------- ------- ----------- ------- -------------- ------ 69 | ; Buffer0 texture struct r/o T0 t0 1 70 | ; BufferOut UAV struct r/w U0 u0 1 71 | ; 72 | target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f:64:64-n8:16:32:64" 73 | target triple = "dxil-ms-dx" 74 | 75 | %dx.types.Handle = type { i8* } 76 | %dx.types.ResRet.i32 = type { i32, i32, i32, i32, i32 } 77 | %class.StructuredBuffer = type { %struct.Pixel } 78 | %struct.Pixel = type { i32 } 79 | %class.RWStructuredBuffer = type { %struct.Pixel } 80 | 81 | define void @main() { 82 | %BufferOut_UAV_structbuf = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) 83 | %Buffer0_texture_structbuf = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) 84 | %1 = call i32 @dx.op.threadId.i32(i32 93, i32 0) ; ThreadId(component) 85 | %2 = call i32 @dx.op.threadId.i32(i32 93, i32 1) ; ThreadId(component) 86 | %3 = shl i32 %2, 10 87 | %4 = add nsw i32 %3, %1 88 | %5 = call %dx.types.ResRet.i32 @dx.op.bufferLoad.i32(i32 68, %dx.types.Handle %Buffer0_texture_structbuf, i32 %4, i32 0) ; BufferLoad(srv,index,wot) 89 | %6 = extractvalue %dx.types.ResRet.i32 %5, 0 90 | %7 = and i32 %6, 255 91 | %8 = uitofp i32 %7 to float 92 | %9 = lshr i32 %6, 8 93 | %10 = and i32 %9, 255 94 | %11 = uitofp i32 %10 to float 95 | %12 = lshr i32 %6, 16 96 | %13 = and i32 %12, 255 97 | %14 = uitofp i32 %13 to float 98 | %15 = fmul fast float %8, 0x3F534679C0000000 99 | %16 = fmul fast float %11, 0x3F62F43BE0000000 100 | %17 = fadd fast float %16, %15 101 | %18 = fmul fast float %14, 0x3F3C453B20000000 102 | %19 = fadd fast float %17, %18 103 | %FMax6 = call float @dx.op.binary.f32(i32 35, float %19, float 0.000000e+00) ; FMax(a,b) 104 | %FMin7 = call float @dx.op.binary.f32(i32 36, float %FMax6, float 1.000000e+00) ; FMin(a,b) 105 | %20 = fmul fast float %FMin7, 2.550000e+02 106 | %21 = fptosi float %20 to i32 107 | %22 = mul i32 %21, 65793 108 | call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle %BufferOut_UAV_structbuf, i32 %4, i32 0, i32 %22, i32 undef, i32 undef, i32 undef, i8 1) ; BufferStore(uav,coord0,coord1,value0,value1,value2,value3,mask) 109 | ret void 110 | } 111 | 112 | ; Function Attrs: nounwind readnone 113 | declare i32 @dx.op.threadId.i32(i32, i32) #0 114 | 115 | ; Function Attrs: nounwind readnone 116 | declare float @dx.op.binary.f32(i32, float, float) #0 117 | 118 | ; Function Attrs: nounwind readonly 119 | declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1 120 | 121 | ; Function Attrs: nounwind 122 | declare void @dx.op.bufferStore.i32(i32, %dx.types.Handle, i32, i32, i32, i32, i32, i32, i8) #2 123 | 124 | ; Function Attrs: nounwind readonly 125 | declare %dx.types.ResRet.i32 @dx.op.bufferLoad.i32(i32, %dx.types.Handle, i32, i32) #1 126 | 127 | attributes #0 = { nounwind readnone } 128 | attributes #1 = { nounwind readonly } 129 | attributes #2 = { nounwind } 130 | 131 | !llvm.ident = !{!0} 132 | !dx.version = !{!1} 133 | !dx.valver = !{!2} 134 | !dx.shaderModel = !{!3} 135 | !dx.resources = !{!4} 136 | !dx.typeAnnotations = !{!10, !15} 137 | !dx.entryPoints = !{!19} 138 | 139 | !0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"} 140 | !1 = !{i32 1, i32 0} 141 | !2 = !{i32 1, i32 3} 142 | !3 = !{!"cs", i32 6, i32 0} 143 | !4 = !{!5, !8, null, null} 144 | !5 = !{!6} 145 | !6 = !{i32 0, %class.StructuredBuffer* undef, !"Buffer0", i32 0, i32 0, i32 1, i32 12, i32 0, !7} 146 | !7 = !{i32 1, i32 4} 147 | !8 = !{!9} 148 | !9 = !{i32 0, %class.RWStructuredBuffer* undef, !"BufferOut", i32 0, i32 0, i32 1, i32 12, i1 false, i1 false, i1 false, !7} 149 | !10 = !{i32 0, %class.StructuredBuffer undef, !11, %struct.Pixel undef, !13, %class.RWStructuredBuffer undef, !11} 150 | !11 = !{i32 4, !12} 151 | !12 = !{i32 6, !"h", i32 3, i32 0} 152 | !13 = !{i32 4, !14} 153 | !14 = !{i32 6, !"colour", i32 3, i32 0, i32 7, i32 4} 154 | !15 = !{i32 1, void ()* @main, !16} 155 | !16 = !{!17} 156 | !17 = !{i32 0, !18, !18} 157 | !18 = !{} 158 | !19 = !{void ()* @main, !"main", null, !4, !20} 159 | !20 = !{i32 0, i64 16, i32 4, !21} 160 | !21 = !{i32 32, i32 16, i32 1} 161 | ``` 162 | --------------------------------------------------------------------------------