mirror of
https://github.com/libretro/parallel-dc.git
synced 2026-11-07 04:25:58 -10:00
Direct3D 12: the raster shaders as DXIL where the device takes shader model 6.0
dx12_dxil.inc has every raster shader and the HDR output's as DXIL, shader model 6.0, made by dxc and signed, each held to the raster root signature (-verifyrootsignature); kernels_dx12.sh update-dxil makes it, and check compares it. DX12Pipelines::Init() asks the device for its shader model before the pipeline file is read: DXIL from 6.0 on, DXBC below, a pipeline's shaders always of one kind. The pipeline file's sum is of the shaders chosen. tools/rend/d3d_dxil.sh runs the test discs on Direct3D 12 as the device answers and with it saying 5.1 (d3d_hdr.c's D3DH_SM51): the shaders are DXIL only where the device takes it, every pipeline is made, and the pictures are the DXBC ones.
This commit is contained in:
1 parent
60a5a324cf
commit
f2f7ef700a
8 files changed
+14145
-11
No files matched your search
@@ -68,6 +68,7 @@ on:
|
||||
- 'core/hw/pvr/helper_classes.h'
|
||||
- 'tools/rend/parse_arena_test.*'
|
||||
- 'tools/rend/d3d_parse_arena.sh'
|
||||
- 'tools/rend/d3d_dxil.sh'
|
||||
- 'tools/rend/dx12_blend_fold_test.*'
|
||||
- 'tools/rend/clip_check.py'
|
||||
- 'tools/threads/live_prog.c'
|
||||
@@ -106,6 +107,7 @@ on:
|
||||
- 'core/hw/pvr/helper_classes.h'
|
||||
- 'tools/rend/parse_arena_test.*'
|
||||
- 'tools/rend/d3d_parse_arena.sh'
|
||||
- 'tools/rend/d3d_dxil.sh'
|
||||
- 'tools/rend/dx12_blend_fold_test.*'
|
||||
- 'tools/rend/clip_check.py'
|
||||
- 'tools/threads/live_prog.c'
|
||||
@@ -189,3 +191,5 @@ jobs:
|
||||
run: VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json sh tools/rend/d3d_dma.sh parallel_dc_libretro.dll
|
||||
- name: Direct3D 12 drawing the frame from where it is parsed, every frame the one of the lists copied
|
||||
run: VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json sh tools/rend/d3d_parse_arena.sh parallel_dc_libretro.dll
|
||||
- name: Direct3D 12's shaders as DXIL where the device takes shader model 6.0, as DXBC where it does not
|
||||
run: VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json sh tools/rend/d3d_dxil.sh parallel_dc_libretro.dll
|
||||
File diff suppressed because it is too large.
Load diff
@@ -568,6 +568,8 @@ bool DX12Pipelines::Init(ID3D12Device *device, ID3D12RootSignature *root, UINT v
|
||||
keys.reserve(MaxKeys);
|
||||
if (FAILED(device->QueryInterface(__uuidof(ID3D12Device1), (void **)&device1)))
|
||||
device1 = nullptr;
|
||||
// (before the file: the library kept is of the shaders chosen)
|
||||
NOTICE_LOG(RENDERER, "DX12: the shaders as %s", dx12_shaders_choose(device) ? "DXIL (shader model 6.0)" : "DXBC (shader model 5.1)");
|
||||
LoadFile();
|
||||
// (after the library: the thread uses it)
|
||||
warm = d3d_warm_new(dx12WarmBuild, dx12WarmRelease, this, MaxKeys * 2);
|
||||
|
||||
@@ -18,13 +18,20 @@
|
||||
#include <cstddef>
|
||||
#include "dx12_dxbc.inc"
|
||||
#include "dx12_hdr_dxbc.inc"
|
||||
#include "dx12_dxil.inc"
|
||||
#include "rend/texdecode_dxbc.inc"
|
||||
#include "deps/xxhash/xxhash.h"
|
||||
|
||||
/* DXIL, where the device takes it: the raster shaders all of one kind,
|
||||
* since a pipeline's are */
|
||||
static bool useDxil;
|
||||
|
||||
D3D12_SHADER_BYTECODE dx12_shader(DX12Shader shader)
|
||||
{
|
||||
const int n = (int)shader;
|
||||
D3D12_SHADER_BYTECODE code = { dx12_dxbc[n], dx12_dxbc_size[n] };
|
||||
if (useDxil)
|
||||
code = { dx12_dxil[n], dx12_dxil_size[n] };
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -32,6 +39,8 @@ D3D12_SHADER_BYTECODE dx12_hdr_shader(DX12HdrShader shader)
|
||||
{
|
||||
const int n = (int)shader;
|
||||
D3D12_SHADER_BYTECODE code = { dx12_hdr_dxbc[n], dx12_hdr_dxbc_size[n] };
|
||||
if (useDxil)
|
||||
code = { dx12_hdr_dxil[n], dx12_hdr_dxil_size[n] };
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -41,17 +50,34 @@ D3D12_SHADER_BYTECODE dx12_texdecode_kernel(int kernel)
|
||||
return code;
|
||||
}
|
||||
|
||||
static u32 hash;
|
||||
|
||||
bool dx12_shaders_choose(ID3D12Device *device)
|
||||
{
|
||||
D3D12_FEATURE_DATA_SHADER_MODEL model{};
|
||||
model.HighestShaderModel = D3D_SHADER_MODEL_6_0;
|
||||
useDxil = SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &model, sizeof(model)))
|
||||
&& model.HighestShaderModel >= D3D_SHADER_MODEL_6_0;
|
||||
hash = 0;
|
||||
return useDxil;
|
||||
}
|
||||
|
||||
u32 dx12_shaders_hash()
|
||||
{
|
||||
static u32 hash;
|
||||
if (hash == 0)
|
||||
{
|
||||
XXH32_state_t *st = XXH32_createState();
|
||||
XXH32_reset(st, 0);
|
||||
XXH32_reset(st, useDxil ? 1 : 0);
|
||||
for (size_t i = 1; i < sizeof(dx12_dxbc) / sizeof(dx12_dxbc[0]); i++)
|
||||
XXH32_update(st, dx12_dxbc[i], dx12_dxbc_size[i]);
|
||||
{
|
||||
const D3D12_SHADER_BYTECODE code = dx12_shader((DX12Shader)i);
|
||||
XXH32_update(st, code.pShaderBytecode, code.BytecodeLength);
|
||||
}
|
||||
for (size_t i = 1; i < sizeof(dx12_hdr_dxbc) / sizeof(dx12_hdr_dxbc[0]); i++)
|
||||
XXH32_update(st, dx12_hdr_dxbc[i], dx12_hdr_dxbc_size[i]);
|
||||
{
|
||||
const D3D12_SHADER_BYTECODE code = dx12_hdr_shader((DX12HdrShader)i);
|
||||
XXH32_update(st, code.pShaderBytecode, code.BytecodeLength);
|
||||
}
|
||||
for (size_t i = 1; i < sizeof(texdecode_dxbc) / sizeof(texdecode_dxbc[0]); i++)
|
||||
XXH32_update(st, texdecode_dxbc[i], texdecode_dxbc_size[i]);
|
||||
hash = XXH32_digest(st) | 1; // (never 0: not worked out yet)
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#pragma once
|
||||
/* The Direct3D 12 renderer's shaders: DXBC made when the core is built
|
||||
* (dx12_dxbc.inc, from shaders/dx12_raster.hlsl, by
|
||||
* tools/rend/kernels_dx12.sh), and the texture kernels the Direct3D 11
|
||||
* tools/rend/kernels_dx12.sh), the same as DXIL for a device of shader
|
||||
* model 6.0 (dx12_dxil.inc), and the texture kernels the Direct3D 11
|
||||
* renderer has (rend/texdecode_dxbc.inc). Nothing is compiled when the
|
||||
* core runs, and it needs no compiler. */
|
||||
#include "rend/d3d_system.h"
|
||||
@@ -83,6 +84,10 @@ enum class DX12HdrShader
|
||||
D3D12_SHADER_BYTECODE dx12_hdr_shader(DX12HdrShader shader);
|
||||
/* rend/texdecode.h's, by TEXD_KERNEL_D3D (1 to 4) */
|
||||
D3D12_SHADER_BYTECODE dx12_texdecode_kernel(int kernel);
|
||||
/* A sum of all of the bytecode above: a pipeline kept on disk was made with
|
||||
* it only if it is the same (dx12_pso.cpp) */
|
||||
/* Whether the raster and HDR shaders above are DXIL (shader model 6.0,
|
||||
* dx12_dxil.inc) or DXBC (5.1): DXIL where @device takes it. Before a
|
||||
* pipeline is made with them. */
|
||||
bool dx12_shaders_choose(ID3D12Device *device);
|
||||
/* A sum of all of the bytecode above, as chosen: a pipeline kept on disk was
|
||||
* made with it only if it is the same (dx12_pso.cpp) */
|
||||
u32 dx12_shaders_hash();
|
||||
+22
-3
@@ -18,7 +18,9 @@
|
||||
* With D3DH_NOT_UMA=1 (Direct3D 12) the adapter says its memory is not the
|
||||
* processor's (CacheCoherentUMA 0, as a card of its own has it): the core
|
||||
* copies the frame's lists to the card, not parse them where it reads
|
||||
* them (tools/rend/d3d_parse_arena.sh). With D3DH_EVERY=1 (Direct3D 12)
|
||||
* them (tools/rend/d3d_parse_arena.sh). With D3DH_SM51=1 (Direct3D 12) the
|
||||
* device's highest shader model is 5.1: the core's raster shaders are
|
||||
* DXBC, not DXIL (tools/rend/d3d_dxil.sh). With D3DH_EVERY=1 (Direct3D 12)
|
||||
* the picture handed over is read back after every frame and its sum
|
||||
* printed, "frame N SUM", for runs to be compared frame for frame (as
|
||||
* gl_frames.c's GLF_EVERY).
|
||||
@@ -110,6 +112,14 @@ static HRESULT STDMETHODCALLTYPE not_uma_check(ID3D12Device *device, D3D12_FEATU
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
/* D3DH_SM51: the same copy, and the device's highest shader model 5.1 */
|
||||
static HRESULT STDMETHODCALLTYPE sm51_check(ID3D12Device *device, D3D12_FEATURE feature, void *data, UINT size)
|
||||
{
|
||||
const HRESULT hr = getenv("D3DH_NOT_UMA") ? not_uma_check(device, feature, data, size) : d12_check(device, feature, data, size);
|
||||
if (SUCCEEDED(hr) && feature == D3D12_FEATURE_SHADER_MODEL && size >= sizeof(D3D12_FEATURE_DATA_SHADER_MODEL))
|
||||
((D3D12_FEATURE_DATA_SHADER_MODEL *)data)->HighestShaderModel = D3D_SHADER_MODEL_5_1;
|
||||
return hr;
|
||||
}
|
||||
static ID3D12CommandQueue *q12;
|
||||
static ID3D12Resource *frame12;
|
||||
static DXGI_FORMAT frame12_format;
|
||||
@@ -632,13 +642,22 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "d3d_hdr: no Direct3D 12 device\n");
|
||||
return 2;
|
||||
}
|
||||
if (getenv("D3DH_NOT_UMA"))
|
||||
if (getenv("D3DH_NOT_UMA") || getenv("D3DH_SM51"))
|
||||
{
|
||||
memcpy(d12_not_uma, d12->lpVtbl, sizeof(d12_not_uma));
|
||||
d12_check = d12->lpVtbl->CheckFeatureSupport;
|
||||
((ID3D12DeviceVtbl *)d12_not_uma)->CheckFeatureSupport = not_uma_check;
|
||||
((ID3D12DeviceVtbl *)d12_not_uma)->CheckFeatureSupport = getenv("D3DH_SM51") ? sm51_check : not_uma_check;
|
||||
d12->lpVtbl = (ID3D12DeviceVtbl *)d12_not_uma;
|
||||
}
|
||||
{
|
||||
/* (what the device says of its shader models, as the core will be
|
||||
* told: tools/rend/d3d_dxil.sh) */
|
||||
D3D12_FEATURE_DATA_SHADER_MODEL sm;
|
||||
sm.HighestShaderModel = D3D_SHADER_MODEL_6_0;
|
||||
if (FAILED(ID3D12Device_CheckFeatureSupport(d12, D3D12_FEATURE_SHADER_MODEL, &sm, sizeof(sm))))
|
||||
sm.HighestShaderModel = D3D_SHADER_MODEL_5_1;
|
||||
printf("d3d_hdr: highest shader model %x\n", (unsigned)sm.HighestShaderModel);
|
||||
}
|
||||
memset(&qd, 0, sizeof(qd));
|
||||
qd.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
if (FAILED(ID3D12Device_CreateCommandQueue(d12, &qd, &IID_ID3D12CommandQueue, (void**)&q12)))
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
# The Direct3D 12 renderer's raster shaders as DXIL where the device takes
|
||||
# shader model 6.0, as DXBC where it does not (dx12/dx12_shaders.h,
|
||||
# dx12_shaders_choose()): the core's Windows build under wine (vkd3d on
|
||||
# lavapipe) on a frontend that runs the core's frames as RetroArch does
|
||||
# (tools/hdr/d3d_hdr.c), the test discs, each translucent sort. Run as the
|
||||
# device answers, the shaders are DXIL if, and only if, it says 6.0 (wine's
|
||||
# vkd3d says 5.1 and takes no DXIL: a core that chose DXIL regardless draws
|
||||
# nothing); run with the device saying 5.1 (D3DH_SM51), DXBC; and the
|
||||
# pictures of the two the same.
|
||||
#
|
||||
# sh tools/rend/d3d_dxil.sh [core.dll]
|
||||
#
|
||||
# KEEP=1: the pictures and logs are kept, in $TMPDIR/d3d_dxil.<pid>.
|
||||
#
|
||||
# Needs wine, Xvfb, mingw-w64 and a Vulkan driver (lavapipe:
|
||||
# VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json).
|
||||
set -e
|
||||
cd "$(dirname "$0")/../.."
|
||||
CORE=$(readlink -f "${1:-parallel_dc_libretro.dll}")
|
||||
WORK=$(readlink -f "${TMPDIR:-/tmp}")/d3d_dxil.$$
|
||||
mkdir -p "$WORK"
|
||||
DISPLAY_NO=${D3D_DXIL_DISPLAY:-:96}
|
||||
Xvfb $DISPLAY_NO -screen 0 640x480x24 >/dev/null 2>&1 &
|
||||
XVFB=$!
|
||||
trap 'kill $XVFB 2>/dev/null; [ -n "${KEEP:-}" ] || rm -rf "$WORK"' EXIT
|
||||
${CC_WIN:-x86_64-w64-mingw32-gcc} -O1 -Wall -I./core/libretro-common/include -I./core/deps/khronos \
|
||||
-o "$WORK/d3d_hdr.exe" tools/hdr/d3d_hdr.c -ld3d11 -ld3d12 -ldxguid
|
||||
for disc in plain cull; do
|
||||
mkdir -p "$WORK/$disc"
|
||||
case $disc in
|
||||
plain) python3 tools/threads/live_disc.py "$WORK/$disc/test.gdi" ;;
|
||||
*) python3 tools/threads/live_disc.py "$WORK/$disc/test.gdi" --$disc ;;
|
||||
esac
|
||||
done
|
||||
fails=0
|
||||
|
||||
# run <disc> <name> <options...>: 100 frames, from nothing kept by an earlier run
|
||||
run() {
|
||||
run_disc=$1; run_name=$2; shift 2
|
||||
rm -rf "$WORK/dir"; mkdir -p "$WORK/dir"
|
||||
env -u TMPDIR DISPLAY=$DISPLAY_NO WINEDEBUG=-all WINE_D3D_CONFIG=renderer=vulkan VKD3D_CONFIG=virtual_heaps \
|
||||
D3DH_VERBOSE=1 D3DH_API=12 D3DH_FRONTEND=sdr D3DH_DIR="Z:$WORK/dir" WINEDLLOVERRIDES="winedbg.exe=d" \
|
||||
timeout 600 wine "$WORK/d3d_hdr.exe" "Z:$CORE" "Z:$WORK/$run_disc/test.gdi" "Z:$WORK/$run_name.raw" 100 "$@" \
|
||||
> "$WORK/$run_name.log" 2>&1 || { echo " FAIL: the $run_name run failed:"; tail -5 "$WORK/$run_name.log"; return 1; }
|
||||
}
|
||||
|
||||
for disc in plain cull; do
|
||||
for r in per-triangle per-strip per-pixel; do
|
||||
case $r in
|
||||
per-triangle) set -- "reicast_alpha_sorting=per-triangle (normal)" ;;
|
||||
per-strip) set -- "reicast_alpha_sorting=per-strip (fast, least accurate)" ;;
|
||||
per-pixel) set -- "reicast_alpha_sorting=per-pixel (accurate)" ;;
|
||||
esac
|
||||
name="$disc-$r"
|
||||
run $disc "$name" "$@" || { fails=$((fails + 1)); continue; }
|
||||
D3DH_SM51=1 run $disc "$name-sm51" "$@" || { fails=$((fails + 1)); continue; }
|
||||
model=$(sed -n 's/^d3d_hdr: highest shader model \([0-9a-f]*\).*/\1/p' "$WORK/$name.log" | head -1)
|
||||
want="DXBC"
|
||||
[ -n "$model" ] && [ $((0x$model)) -ge $((0x60)) ] && want="DXIL"
|
||||
chose=$(sed -n 's/.*DX12: the shaders as \([A-Z]*\).*/\1/p' "$WORK/$name.log" | head -1)
|
||||
chose51=$(sed -n 's/.*DX12: the shaders as \([A-Z]*\).*/\1/p' "$WORK/$name-sm51.log" | head -1)
|
||||
echo "$name: the device says shader model ${model:-?}: $chose; said 5.1: $chose51"
|
||||
if [ "$chose" != "$want" ] || [ "$chose51" != "DXBC" ]; then
|
||||
echo " FAIL: the shaders are not the ones the device's shader model calls for"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
if grep -q "could not be made" "$WORK/$name.log" "$WORK/$name-sm51.log"; then
|
||||
echo " FAIL: a pipeline could not be made with the shaders chosen"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
if [ ! -s "$WORK/$name.raw" ] || ! cmp -s "$WORK/$name.raw" "$WORK/$name-sm51.raw"; then
|
||||
echo " FAIL: the picture is not the DXBC one"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
[ $fails -eq 0 ] || { echo "d3d_dxil: $fails failed"; exit 1; }
|
||||
echo "d3d_dxil: all passed"
|
||||
@@ -74,6 +74,7 @@
|
||||
# sh tools/rend/kernels_dx12.sh update all made again from the sources
|
||||
# sh tools/rend/kernels_dx12.sh update-raster only the raster shaders' DXBC (dx12_dxbc.inc) made again
|
||||
# sh tools/rend/kernels_dx12.sh update-hdr only the HDR output's DXBC made again
|
||||
# sh tools/rend/kernels_dx12.sh update-dxil only the raster and HDR shaders' DXIL (dx12_dxil.inc) made again
|
||||
# sh tools/rend/kernels_dx12.sh update-compute-hdr ...and its DXIL
|
||||
# sh tools/rend/kernels_dx12.sh update-compute-upscaler only the upscaler's DXIL made again
|
||||
# sh tools/rend/kernels_dx12.sh check whether all are the sources' still
|
||||
@@ -146,6 +147,10 @@ COUNT=43
|
||||
# the per-pixel renderer's lists resolved with SSAA (34's) that store the
|
||||
# channel sums as well
|
||||
HDR_INC=core/rend/dx12/dx12_hdr_dxbc.inc
|
||||
# The same shaders, raster and HDR, as DXIL (shader model 6.0, HLSL 2018 as
|
||||
# the DXBC's source is written), for a device that takes it
|
||||
# (dx12_shaders.cpp): made by dxc, which signs them
|
||||
DXIL_INC=core/rend/dx12/dx12_dxil.inc
|
||||
HDR_SHADERS="1:ps_5_1:DX12_OIT_FINAL_PS,$S,DX12_MS_TABLE,DX12_OIT_SUMS"
|
||||
HDR_COUNT=1
|
||||
TA_INC=core/rend/dx12/dx12_ta_dxbc.inc
|
||||
@@ -599,6 +604,88 @@ hdr_sums() {
|
||||
done
|
||||
}
|
||||
|
||||
# The raster renderers' root signature (dx12/dx12context_lr.cpp's, as it
|
||||
# has it), which dxc holds each raster shader's DXIL bindings to
|
||||
# (-verifyrootsignature): the polygon's constants, the vertex and fragment
|
||||
# constants, the bindless textures and samplers, the per-pixel renderer's
|
||||
# table and parameters, the HDR sums, the point and linear samplers
|
||||
V="visibility=SHADER_VISIBILITY_PIXEL"
|
||||
RASTER_ROOT="RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), RootConstants(num32BitConstants=14, b1), CBV(b0, visibility=SHADER_VISIBILITY_VERTEX), CBV(b2, $V), DescriptorTable(SRV(t0, space=1, numDescriptors=16384), $V), DescriptorTable(Sampler(s0, space=1, numDescriptors=1024), $V), DescriptorTable(UAV(u1, numDescriptors=3), SRV(t4, offset=3), SRV(t6, offset=4), $V), SRV(t5, $V), DescriptorTable(UAV(u4), $V)"
|
||||
RASTER_ROOT="$RASTER_ROOT, StaticSampler(s0, filter=FILTER_MIN_MAG_MIP_POINT, addressU=TEXTURE_ADDRESS_CLAMP, addressV=TEXTURE_ADDRESS_CLAMP, addressW=TEXTURE_ADDRESS_CLAMP, comparisonFunc=COMPARISON_NEVER, borderColor=STATIC_BORDER_COLOR_TRANSPARENT_BLACK, $V)"
|
||||
RASTER_ROOT="$RASTER_ROOT, StaticSampler(s1, filter=FILTER_MIN_MAG_MIP_LINEAR, addressU=TEXTURE_ADDRESS_CLAMP, addressV=TEXTURE_ADDRESS_CLAMP, addressW=TEXTURE_ADDRESS_CLAMP, comparisonFunc=COMPARISON_NEVER, borderColor=STATIC_BORDER_COLOR_TRANSPARENT_BLACK, $V)"
|
||||
raster_root() {
|
||||
[ -f "$WORK/raster_root.bin" ] && return
|
||||
echo "#define ROOT \"$RASTER_ROOT\"" > "$WORK/raster_root.hlsl"
|
||||
"$DXC" -T rootsig_1_0 -E ROOT -Fo "$WORK/raster_root.bin" "$WORK/raster_root.hlsl" > "$WORK/log" 2>&1 || { cat "$WORK/log" >&2; exit 1; }
|
||||
}
|
||||
|
||||
# a profile of shader model 5.1 as 6.0's
|
||||
dxil_profile() {
|
||||
echo "$1" | sed 's/_5_1$/_6_0/'
|
||||
}
|
||||
|
||||
dxil_sums() {
|
||||
for k in $SHADERS; do
|
||||
n=${k%%:*}; r=${k#*:}; p=${r%%:*}; d=${r#*:}
|
||||
source_of $d > "$WORK/s.hlsl"
|
||||
echo " * shader $n $(dxil_profile $p) $(sha1sum < "$WORK/s.hlsl" | cut -c1-40)"
|
||||
done
|
||||
for k in $HDR_SHADERS; do
|
||||
n=${k%%:*}; r=${k#*:}; p=${r%%:*}; d=${r#*:}
|
||||
source_of $d > "$WORK/s.hlsl"
|
||||
echo " * shader hdr-$n $(dxil_profile $p) $(sha1sum < "$WORK/s.hlsl" | cut -c1-40)"
|
||||
done
|
||||
}
|
||||
|
||||
# @1 the source, @2 the profile, @3 the DXIL: bound as the root signature has it
|
||||
dxil_compile() {
|
||||
raster_root
|
||||
"$DXC" -T $2 -E main -HV 2018 -O3 -Qstrip_reflect -Qstrip_debug -Fo "$3" "$1" > "$WORK/log" 2>&1 || { cat "$WORK/log" >&2; exit 1; }
|
||||
"$DXC" -dumpbin -verifyrootsignature "$WORK/raster_root.bin" "$3" > "$WORK/log" 2>&1 \
|
||||
|| { cat "$WORK/log" >&2; echo "$0: $1 binds what the raster root signature does not have" >&2; exit 1; }
|
||||
[ "$(od -An -v -tx1 -j4 -N16 "$3" | tr -d ' \n')" != "00000000000000000000000000000000" ] \
|
||||
|| { echo "$0: $DXC did not sign $3 (no dxil.dll or libdxil.so beside it?)" >&2; exit 1; }
|
||||
}
|
||||
|
||||
make_dxil_inc() {
|
||||
echo "/* DXIL of the Direct3D 12 renderer's shaders (rend/dx12/shaders/dx12_raster.hlsl,"
|
||||
echo " * each with its defines and rend/dx12/dx12_shader_flags.h), as dx12_dxbc.inc"
|
||||
echo " * and dx12_hdr_dxbc.inc have them, by the same numbers: made by"
|
||||
echo " * tools/rend/kernels_dx12.sh update-dxil from them. Not to be edited."
|
||||
echo " * dxc $(dxc_version)"
|
||||
dxil_sums
|
||||
echo " */"
|
||||
for k in $SHADERS; do
|
||||
n=${k%%:*}; r=${k#*:}; p=${r%%:*}; d=${r#*:}
|
||||
source_of $d > "$WORK/x$n.hlsl"
|
||||
dxil_compile "$WORK/x$n.hlsl" $(dxil_profile $p) "$WORK/x$n.dxil"
|
||||
echo "static const unsigned char dx12_dxil_$n[] = {"
|
||||
od -An -v -tx1 -w16 "$WORK/x$n.dxil" | awk '{ s = ""; for (i = 1; i <= NF; i++) s = s "0x" $i ","; print s }'
|
||||
echo "};"
|
||||
done
|
||||
for k in $HDR_SHADERS; do
|
||||
n=${k%%:*}; r=${k#*:}; p=${r%%:*}; d=${r#*:}
|
||||
source_of $d > "$WORK/y$n.hlsl"
|
||||
dxil_compile "$WORK/y$n.hlsl" $(dxil_profile $p) "$WORK/y$n.dxil"
|
||||
echo "static const unsigned char dx12_hdr_dxil_$n[] = {"
|
||||
od -An -v -tx1 -w16 "$WORK/y$n.dxil" | awk '{ s = ""; for (i = 1; i <= NF; i++) s = s "0x" $i ","; print s }'
|
||||
echo "};"
|
||||
done
|
||||
echo "// by DX12Shader and DX12HdrShader: the bytes, and how many"
|
||||
l="static const unsigned char * const dx12_dxil[] = { 0"
|
||||
z="static const size_t dx12_dxil_size[] = { 0"
|
||||
i=1
|
||||
while [ $i -le $COUNT ]; do l="$l, dx12_dxil_$i"; z="$z, sizeof(dx12_dxil_$i)"; i=$((i + 1)); done
|
||||
echo "$l };"
|
||||
echo "$z };"
|
||||
l="static const unsigned char * const dx12_hdr_dxil[] = { 0"
|
||||
z="static const size_t dx12_hdr_dxil_size[] = { 0"
|
||||
i=1
|
||||
while [ $i -le $HDR_COUNT ]; do l="$l, dx12_hdr_dxil_$i"; z="$z, sizeof(dx12_hdr_dxil_$i)"; i=$((i + 1)); done
|
||||
echo "$l };"
|
||||
echo "$z };"
|
||||
}
|
||||
|
||||
make_hdr_inc() {
|
||||
echo "/* DXBC of the Direct3D 12 renderer's shaders for the HDR output"
|
||||
echo " * (rend/dx12/shaders/dx12_raster.hlsl, each with its defines and"
|
||||
@@ -643,6 +730,12 @@ update-raster)
|
||||
cp "$WORK/new.inc" $INC
|
||||
echo "made $INC"
|
||||
;;
|
||||
update-dxil)
|
||||
[ -n "$(dxc_version)" ] || { echo "$0: DXC=/path/to/dxc is needed to make them" >&2; exit 1; }
|
||||
make_dxil_inc > "$WORK/new.inc"
|
||||
cp "$WORK/new.inc" $DXIL_INC
|
||||
echo "made $DXIL_INC"
|
||||
;;
|
||||
update-hdr)
|
||||
[ -n "$(compiler_sum)" ] || { echo "$0: D3DCOMPILER=/path/to/d3dcompiler_47.dll is needed to make them" >&2; exit 1; }
|
||||
make_hdr_inc > "$WORK/new.inc"
|
||||
@@ -666,7 +759,9 @@ update)
|
||||
cp "$WORK/new.inc" $COMPUTE_HDR_INC
|
||||
make_compute_upscaler_inc > "$WORK/new.inc"
|
||||
cp "$WORK/new.inc" $COMPUTE_UPSCALER_INC
|
||||
echo "made $INC, $TA_INC, $TA11_INC, $COMPUTE_INC, $HDR_INC, $COMPUTE_HDR_INC and $COMPUTE_UPSCALER_INC"
|
||||
make_dxil_inc > "$WORK/new.inc"
|
||||
cp "$WORK/new.inc" $DXIL_INC
|
||||
echo "made $INC, $TA_INC, $TA11_INC, $COMPUTE_INC, $HDR_INC, $COMPUTE_HDR_INC, $COMPUTE_UPSCALER_INC and $DXIL_INC"
|
||||
;;
|
||||
check)
|
||||
check_inc $INC make_inc sums d3dcompiler_47
|
||||
@@ -674,6 +769,7 @@ check)
|
||||
check_inc $TA11_INC make_ta11_inc ta11_sums d3dcompiler_47
|
||||
check_inc $COMPUTE_INC make_compute_inc compute_sums dxc
|
||||
check_inc $HDR_INC make_hdr_inc hdr_sums d3dcompiler_47
|
||||
check_inc $DXIL_INC make_dxil_inc dxil_sums dxc
|
||||
check_inc $COMPUTE_HDR_INC make_compute_hdr_inc compute_hdr_sums dxc
|
||||
check_inc $COMPUTE_UPSCALER_INC make_compute_upscaler_inc compute_upscaler_sums dxc
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user