mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
Compare commits
3 Commits
vkd3d-1.15
...
vkd3d-1.7.
Author | SHA1 | Date | |
---|---|---|---|
|
154acd2c2b | ||
|
cb2acc35f2 | ||
|
7b9b0179ec |
@@ -1,16 +0,0 @@
|
|||||||
# https://editorconfig.org/
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
tab_width = 8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
max_line_length = 120
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[Makefile*]
|
|
||||||
indent_style = tab
|
|
||||||
indent_size = 8
|
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,7 +10,6 @@ Makefile
|
|||||||
Makefile.in
|
Makefile.in
|
||||||
test-suite.log
|
test-suite.log
|
||||||
/vkd3d-compiler
|
/vkd3d-compiler
|
||||||
/vkd3d-dxbc
|
|
||||||
|
|
||||||
vkd3d-*.tar.xz
|
vkd3d-*.tar.xz
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ vkd3d-*.tar.xz
|
|||||||
*.tab.c
|
*.tab.c
|
||||||
*.tab.h
|
*.tab.h
|
||||||
*.trs
|
*.trs
|
||||||
*.txt
|
|
||||||
*.yy.c
|
*.yy.c
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
stages:
|
|
||||||
- image
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
include:
|
|
||||||
- local: "/gitlab/image.yml"
|
|
||||||
- local: "/gitlab/build.yml"
|
|
||||||
- local: "/gitlab/test.yml"
|
|
||||||
- local: "/gitlab/release.yml"
|
|
2
.mailmap
2
.mailmap
@@ -1,2 +0,0 @@
|
|||||||
Elizabeth Figura <z.figura12@gmail.com>
|
|
||||||
Elizabeth Figura <zfigura@codeweavers.com>
|
|
16
AUTHORS
16
AUTHORS
@@ -1,10 +1,6 @@
|
|||||||
Akihiro Sagawa
|
|
||||||
Alexandre Julliard
|
Alexandre Julliard
|
||||||
Alistair Leslie-Hughes
|
|
||||||
Andrew Eikum
|
Andrew Eikum
|
||||||
Andrey Gusev
|
Andrey Gusev
|
||||||
Anna (navi) Figueiredo Gomes
|
|
||||||
Arkadiusz Hiler
|
|
||||||
Atharva Nimbalkar
|
Atharva Nimbalkar
|
||||||
Biswapriyo Nath
|
Biswapriyo Nath
|
||||||
Brendan Shanks
|
Brendan Shanks
|
||||||
@@ -12,34 +8,24 @@ Chip Davis
|
|||||||
Conor McCarthy
|
Conor McCarthy
|
||||||
David Gow
|
David Gow
|
||||||
Derek Lesho
|
Derek Lesho
|
||||||
Elizabeth Figura
|
|
||||||
Ethan Lee
|
|
||||||
Evan Tang
|
|
||||||
Fabian Maurer
|
Fabian Maurer
|
||||||
Feifan He
|
|
||||||
Florian Weimer
|
|
||||||
Francisco Casas
|
Francisco Casas
|
||||||
Francois Gouget
|
Francois Gouget
|
||||||
Giovanni Mascellani
|
Giovanni Mascellani
|
||||||
Hans-Kristian Arntzen
|
Hans-Kristian Arntzen
|
||||||
Henri Verbeet
|
Henri Verbeet
|
||||||
Isabella Bosia
|
Isabella Bosia
|
||||||
Jacek Caban
|
|
||||||
Jactry Zeng
|
Jactry Zeng
|
||||||
Jan Sikorski
|
|
||||||
Joshua Ashton
|
Joshua Ashton
|
||||||
JĂłzef Kucia
|
JĂłzef Kucia
|
||||||
Martin Storsjö
|
Martin Storsjö
|
||||||
Matteo Bruni
|
Matteo Bruni
|
||||||
Nikolay Sivov
|
Nikolay Sivov
|
||||||
Petrichor Park
|
|
||||||
Philip Rebohle
|
Philip Rebohle
|
||||||
Rémi Bernon
|
Rémi Bernon
|
||||||
Robin Kertels
|
Robin Kertels
|
||||||
Shaun Ren
|
|
||||||
Stefan Dösinger
|
Stefan Dösinger
|
||||||
Sven Hesse
|
Sven Hesse
|
||||||
Victor Chiletto
|
|
||||||
Vinson Lee
|
Vinson Lee
|
||||||
Yuxuan Shui
|
Zebediah Figura
|
||||||
Zhiyi Zhang
|
Zhiyi Zhang
|
||||||
|
2
COPYING
2
COPYING
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2016-2025 the Vkd3d project authors (see the file AUTHORS for a
|
Copyright 2016-2023 the Vkd3d project authors (see the file AUTHORS for a
|
||||||
complete list)
|
complete list)
|
||||||
|
|
||||||
Vkd3d is free software; you can redistribute it and/or modify it under
|
Vkd3d is free software; you can redistribute it and/or modify it under
|
||||||
|
1471
ChangeLog.md
1471
ChangeLog.md
File diff suppressed because it is too large
Load Diff
@@ -8,10 +8,6 @@ OUTPUT_DIRECTORY = doc
|
|||||||
JAVADOC_AUTOBRIEF = YES
|
JAVADOC_AUTOBRIEF = YES
|
||||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
EXTRACT_STATIC = YES
|
EXTRACT_STATIC = YES
|
||||||
QUIET = YES
|
|
||||||
WARN_IF_UNDOCUMENTED = NO
|
|
||||||
WARN_IF_INCOMPLETE_DOC = NO
|
|
||||||
LATEX_BATCHMODE = YES
|
|
||||||
|
|
||||||
INPUT = @srcdir@/include/vkd3d.h \
|
INPUT = @srcdir@/include/vkd3d.h \
|
||||||
@srcdir@/include/vkd3d_shader.h \
|
@srcdir@/include/vkd3d_shader.h \
|
||||||
|
478
Makefile.am
478
Makefile.am
File diff suppressed because it is too large
Load Diff
156
README
156
README
@@ -9,30 +9,20 @@ similar, but not identical, to Direct3D 12.
|
|||||||
Building vkd3d
|
Building vkd3d
|
||||||
==============
|
==============
|
||||||
|
|
||||||
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228).
|
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.2.139).
|
||||||
|
|
||||||
Vkd3d generates some of its headers from IDL files. If you are using the
|
Vkd3d generates some of its headers from IDL files. If you are using the
|
||||||
release tarballs, then these headers are pre-generated and are included. If
|
release tarballs, then these headers are pre-generated and are included. If
|
||||||
you are building from git, then they will be generated at build-time using
|
you are building from git, then they will be generated at build-time using
|
||||||
widl. By default, vkd3d will use the widl found in `PATH'. If widl is not
|
widl. By default, vkd3d will use the widl found in `PATH'. If widl is not
|
||||||
available or is not recent (>= 3.21), then you can build Wine with `make
|
available or is not recent (>= 3.20), then you can build Wine with `make
|
||||||
tools/widl/widl' to avoid building all of Wine. You can then point vkd3d's
|
tools/widl' to avoid building all of Wine. You can then point vkd3d's
|
||||||
configure at that widl binary with `WIDL="/path/to/widl"'.
|
configure at that widl binary with `WIDL="/path/to/widl"'.
|
||||||
|
|
||||||
For release builds, you may want to disable debug log messages defining
|
For release builds, you may want to define NDEBUG. If you do not need debug log
|
||||||
preprocessor macros VKD3D_NO_TRACE_MESSAGES and VKD3D_NO_DEBUG_MESSAGES.
|
messages, you may also consider VKD3D_NO_TRACE_MESSAGES and
|
||||||
See the `Preprocessor definitions' section below for more details.
|
VKD3D_NO_DEBUG_MESSAGES. For example, you can pass `CPPFLAGS="-DNDEBUG
|
||||||
|
-DVKD3D_NO_TRACE_MESSAGES"' to configure.
|
||||||
================
|
|
||||||
Developing vkd3d
|
|
||||||
================
|
|
||||||
|
|
||||||
Development of vkd3d happens on the Wine GitLab instance
|
|
||||||
(https://gitlab.winehq.org/wine/vkd3d/). Contributors are encouraged
|
|
||||||
to submit their patches using the merge request tool.
|
|
||||||
|
|
||||||
Each merge request is automatically tested with the GitLab CI
|
|
||||||
system. See gitlab/README in the Git tree for more details.
|
|
||||||
|
|
||||||
===========
|
===========
|
||||||
Using vkd3d
|
Using vkd3d
|
||||||
@@ -49,16 +39,16 @@ Environment variables
|
|||||||
=====================
|
=====================
|
||||||
|
|
||||||
Most of the environment variables used by vkd3d are for debugging purposes. The
|
Most of the environment variables used by vkd3d are for debugging purposes. The
|
||||||
environment variables are not considered a stable interface and might be changed
|
environment variables are not considered a part of API and might be changed or
|
||||||
or removed in future versions of vkd3d.
|
removed in the future versions of vkd3d.
|
||||||
|
|
||||||
Some of debug variables are lists of elements. Elements must be separated by
|
Some of debug variables are lists of elements. Elements must be separated by
|
||||||
commas or semicolons.
|
commas or semicolons.
|
||||||
|
|
||||||
* NO_COLOR - this is an alias of NO_COLOUR.
|
* NO_COLOR - this is an alias of NO_COLOUR.
|
||||||
|
|
||||||
* NO_COLOUR - when set, vkd3d-compiler and vkd3d-dxbc will default to
|
* NO_COLOUR - when set, vkd3d-compiler will default to monochrome output,
|
||||||
monochrome output, even when the output supports colour.
|
even when the output supports colour.
|
||||||
|
|
||||||
* VKD3D_CONFIG - a list of options that change the behavior of libvkd3d.
|
* VKD3D_CONFIG - a list of options that change the behavior of libvkd3d.
|
||||||
* virtual_heaps - Create descriptors for each D3D12 root signature
|
* virtual_heaps - Create descriptors for each D3D12 root signature
|
||||||
@@ -75,19 +65,6 @@ commas or semicolons.
|
|||||||
* VKD3D_DISABLE_EXTENSIONS - a list of Vulkan extensions that libvkd3d should
|
* VKD3D_DISABLE_EXTENSIONS - a list of Vulkan extensions that libvkd3d should
|
||||||
not use even if available.
|
not use even if available.
|
||||||
|
|
||||||
* VKD3D_CAPS_OVERRIDE - a list of Direct3D 12 capabilities for which the
|
|
||||||
default value detected by vkd3d should be overridden, in the form
|
|
||||||
`capability1=value1,capability2=value2'. This doesn't change the vkd3d
|
|
||||||
behaviour, only the information reported to the application. The following
|
|
||||||
capabilities can currently be overridden:
|
|
||||||
* feature_level (allowed values: 11.0, 11.1, 12.0, 12.1, 12.2)
|
|
||||||
* resource_binding_tier (allowed values: 1, 2, 3)
|
|
||||||
|
|
||||||
* VKD3D_SHADER_CONFIG - a list of options that change the behavior of
|
|
||||||
libvkd3d-shader.
|
|
||||||
* force_validation - Enable (additional) validation of libvkd3d-shader's
|
|
||||||
internal representation of shaders.
|
|
||||||
|
|
||||||
* VKD3D_SHADER_DEBUG - controls the debug level for log messages produced by
|
* VKD3D_SHADER_DEBUG - controls the debug level for log messages produced by
|
||||||
libvkd3d-shader. See VKD3D_DEBUG for accepted values.
|
libvkd3d-shader. See VKD3D_DEBUG for accepted values.
|
||||||
|
|
||||||
@@ -96,10 +73,6 @@ commas or semicolons.
|
|||||||
* VKD3D_TEST_DEBUG - enables additional debug messages in tests. Set to 0, 1
|
* VKD3D_TEST_DEBUG - enables additional debug messages in tests. Set to 0, 1
|
||||||
or 2.
|
or 2.
|
||||||
|
|
||||||
* VKD3D_TEST_DETAILED - enables printing detailed output when running the test
|
|
||||||
suite, reporting specific shader_test lines that trigger XFAIL and SKIP even
|
|
||||||
on tests that overall PASS. Set to 0, or 1.
|
|
||||||
|
|
||||||
* VKD3D_TEST_FILTER - a filter string. Only the tests whose names matches the
|
* VKD3D_TEST_FILTER - a filter string. Only the tests whose names matches the
|
||||||
filter string will be run, e.g. VKD3D_TEST_FILTER=clear_render_target.
|
filter string will be run, e.g. VKD3D_TEST_FILTER=clear_render_target.
|
||||||
Useful for debugging or developing new tests.
|
Useful for debugging or developing new tests.
|
||||||
@@ -108,111 +81,4 @@ commas or semicolons.
|
|||||||
platform controls the behavior of todo(), todo_if(), bug_if() and broken()
|
platform controls the behavior of todo(), todo_if(), bug_if() and broken()
|
||||||
conditions in tests.
|
conditions in tests.
|
||||||
|
|
||||||
* VKD3D_TEST_SKIP_DXC - when set, tests requiring the dxcompiler library will
|
|
||||||
be skipped.
|
|
||||||
|
|
||||||
* VKD3D_TEST_BUG - set to 0 to disable bug_if() conditions in tests.
|
* VKD3D_TEST_BUG - set to 0 to disable bug_if() conditions in tests.
|
||||||
|
|
||||||
If the configuration defines 'DXCOMPILER_LIBS=-L/path/to/dxcompiler', Shader
|
|
||||||
Runner attempts to load libdxcompiler.so or dxcompiler.dll to compile test
|
|
||||||
shaders in Shader Model 6. LD_LIBRARY_PATH (linux), WINEPATH (wine) or PATH
|
|
||||||
(native windows) should include the location of dxcompiler if SM 6 shader
|
|
||||||
tests are desired. If dxcompiler is not found, Shader Runner will compile the
|
|
||||||
test shaders only in earlier shader models. The DXC source does not contain
|
|
||||||
code for adding DXBC checksums, so the official release should be installed
|
|
||||||
from:
|
|
||||||
https://github.com/microsoft/DirectXShaderCompiler/releases
|
|
||||||
|
|
||||||
========================
|
|
||||||
Preprocessor definitions
|
|
||||||
========================
|
|
||||||
|
|
||||||
A number of preprocessor definitions can be used at compilation time to control
|
|
||||||
the behaviour of the generated binary. You can pass something like
|
|
||||||
`CPPFLAGS="-DVKD3D_VAR1 -DVKD3D_VAR2"' to the configure script. The preprocessor
|
|
||||||
variables are not considered a stable interface and might be changed or removed
|
|
||||||
in future versions of vkd3d.
|
|
||||||
|
|
||||||
* VKD3D_NO_TRACE_MESSAGES - do not emit trace messages in the debug log; this
|
|
||||||
can be useful in release builds to reduce the size of the binary and make it
|
|
||||||
slightly faster.
|
|
||||||
|
|
||||||
* VKD3D_NO_DEBUG_MESSAGES - do not emit warn and fixme messages in the debug
|
|
||||||
log; this will further optimise the binary, but may omit messages that could
|
|
||||||
help debug problems with vkd3d.
|
|
||||||
|
|
||||||
* VKD3D_NO_ERROR_MESSAGES - do not emit error messages; this will optimise the
|
|
||||||
binary even more, but may omit very important messages, so it is not
|
|
||||||
recommended in most circumstances.
|
|
||||||
|
|
||||||
* VKD3D_ABORT_ON_ERR - abort the process as soon as an error message is
|
|
||||||
emitted; this can be useful for developers to make error conditions as
|
|
||||||
conspicuous as possible.
|
|
||||||
|
|
||||||
* VKD3D_SHADER_UNSUPPORTED_DXIL - enable DXIL (DirectX Intermediate Language)
|
|
||||||
support in vkd3d-shader, which is disabled by default because it is not
|
|
||||||
considered ready for release yet. Please note that this feature is not
|
|
||||||
currently supported, and it might change in a non-compatible way before it is
|
|
||||||
released.
|
|
||||||
|
|
||||||
* VKD3D_SHADER_UNSUPPORTED_GLSL - enable GLSL (GL Shading Language) support in
|
|
||||||
vkd3d-shader, which is disabled by default because it is not considered ready
|
|
||||||
for release yet. Please note that this feature is not currently supported,
|
|
||||||
and it might change in a non-compatible way before it is released.
|
|
||||||
|
|
||||||
* VKD3D_SHADER_UNSUPPORTED_MSL - enable MSL (Metal Shading Language) support in
|
|
||||||
vkd3d-shader, which is disabled by default because it is not considered ready
|
|
||||||
for release yet. Please note that this feature is not currently supported,
|
|
||||||
and it might change in a non-compatible way before it is released.
|
|
||||||
|
|
||||||
* VKD3D_SHADER_UNSUPPORTED_SPIRV_PARSER - enable SPIR-V parser support in
|
|
||||||
vkd3d-shader, which is disabled by default because it is not considered ready
|
|
||||||
for release yet. Please note that this feature is not currently supported,
|
|
||||||
and it might change in a non-compatible way before it is released.
|
|
||||||
|
|
||||||
============================
|
|
||||||
Testing with the Agility SDK
|
|
||||||
============================
|
|
||||||
|
|
||||||
Traditionally Microsoft have released the Direct3D 12 development files,
|
|
||||||
including the debug layer runtime, as part of the larger Windows SDK.
|
|
||||||
In 2021 the DirectX 12 Agility SDK was introduced, which may be updated
|
|
||||||
independently of the Windows SDK. If you plan to run the vkd3d
|
|
||||||
crosstests with Microsoft's debug layer you might want to get it from
|
|
||||||
the Agility SDK, both because it's probably going to be more up-to-date
|
|
||||||
and because the Agility SDK is a couple dozens of megabytes versus the
|
|
||||||
gigabytes of the Windows SDK.
|
|
||||||
|
|
||||||
In order to build the vkd3d crosstests with Agility SDK support, follow
|
|
||||||
these steps:
|
|
||||||
|
|
||||||
* The Agility SDK is distributed at [1]: select your preferred
|
|
||||||
version (likely the most recent one) and note the number in column
|
|
||||||
D3D12SDKVersion, which you're going to need later.
|
|
||||||
|
|
||||||
[1] https://devblogs.microsoft.com/directx/directx12agility/
|
|
||||||
|
|
||||||
* You also need to enable the "Graphics Tools" optional feature in Windows.
|
|
||||||
Open the "Settings" applications, then look for "Apps", "Optional features",
|
|
||||||
"View features" and install "Graphics Tools".
|
|
||||||
|
|
||||||
* Configure vkd3d with something like:
|
|
||||||
'CROSSCC64="x86_64-w64-mingw32-gcc -DVKD3D_AGILITY_SDK_VERSION=<version>"',
|
|
||||||
as well as the equivalent CROSSCC32 variable for the 32-bit
|
|
||||||
crosstests. You'll have to replace '<version>' with the
|
|
||||||
D3D12SDKVersion number you noted above. Then build the crosstests
|
|
||||||
with 'make crosstest' as usual.
|
|
||||||
|
|
||||||
* Download the Agility SDK NuGet package, which is essentially a ZIP
|
|
||||||
file with a .nupkg extension. Extract d3d12core.dll and
|
|
||||||
d3d12sdklayers.dll for your architecture, and put them in the
|
|
||||||
directory containing the crosstest executables.
|
|
||||||
|
|
||||||
* Now you can run the crosstests, possibly with arguments
|
|
||||||
'--validate' and '--gbv' to enable the debug layers. They will use
|
|
||||||
the runtime from the Agility SDK.
|
|
||||||
|
|
||||||
* It's also possible to use '-DVKD3D_AGILITY_SDK_PATH=/path/to/sdk/' to
|
|
||||||
specify the directory to load the Agility SDK DLLs from at runtime.
|
|
||||||
If relative, the path is intended to be relative to the executable
|
|
||||||
path. If unspecified the path defaults to './'.
|
|
||||||
|
48
configure.ac
48
configure.ac
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([vkd3d],[1.15])
|
AC_INIT([vkd3d],[1.7.1])
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR([bin])
|
AC_CONFIG_AUX_DIR([bin])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
@@ -8,9 +8,7 @@ AC_CONFIG_HEADERS(include/config.h)
|
|||||||
AC_ARG_VAR([WIDL], [widl IDL compiler])
|
AC_ARG_VAR([WIDL], [widl IDL compiler])
|
||||||
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
|
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
|
||||||
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
|
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
|
||||||
AC_ARG_WITH([metal], AS_HELP_STRING([--with-metal], [Build with the Metal library (default: test)]))
|
|
||||||
AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)]))
|
AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)]))
|
||||||
AC_ARG_WITH([opengl], AS_HELP_STRING([--with-opengl], [Build with the OpenGL library (default: test)]))
|
|
||||||
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
|
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
|
||||||
[Build with SPIRV-Tools library (default: disabled)]))
|
[Build with SPIRV-Tools library (default: disabled)]))
|
||||||
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
|
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
|
||||||
@@ -29,7 +27,7 @@ AC_PROG_CC
|
|||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
AC_PROG_SED
|
AC_PROG_SED
|
||||||
AC_PROG_MKDIR_P
|
AC_PROG_MKDIR_P
|
||||||
VKD3D_PROG_WIDL(3, 21)
|
VKD3D_PROG_WIDL(3, 20)
|
||||||
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
|
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
|
||||||
|
|
||||||
AC_CHECK_PROGS([FLEX], [flex], [none])
|
AC_CHECK_PROGS([FLEX], [flex], [none])
|
||||||
@@ -56,23 +54,16 @@ gl_LD_VERSION_SCRIPT
|
|||||||
dnl Check compiler specific flags
|
dnl Check compiler specific flags
|
||||||
AC_SUBST([VKD3D_CFLAGS])
|
AC_SUBST([VKD3D_CFLAGS])
|
||||||
AS_IF([test "x${GCC}" = "xyes"],
|
AS_IF([test "x${GCC}" = "xyes"],
|
||||||
[VKD3D_CFLAGS="-Wall -pipe -D_WIN32_WINNT=0x0600"
|
[VKD3D_CFLAGS="-Wall -pipe"
|
||||||
VKD3D_CHECK_CFLAGS([-std=c99])
|
VKD3D_CHECK_CFLAGS([-std=c99])
|
||||||
VKD3D_CHECK_CFLAGS([-flto=auto])
|
|
||||||
VKD3D_CHECK_CFLAGS([-fvisibility=hidden])
|
VKD3D_CHECK_CFLAGS([-fvisibility=hidden])
|
||||||
VKD3D_CHECK_CFLAGS([-Wdeclaration-after-statement])
|
VKD3D_CHECK_CFLAGS([-Wdeclaration-after-statement])
|
||||||
VKD3D_CHECK_CFLAGS([-Wempty-body])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wenum-conversion])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wimplicit-fallthrough])
|
VKD3D_CHECK_CFLAGS([-Wimplicit-fallthrough])
|
||||||
VKD3D_CHECK_CFLAGS([-Winit-self])
|
VKD3D_CHECK_CFLAGS([-Winit-self])
|
||||||
VKD3D_CHECK_CFLAGS([-Wmissing-prototypes])
|
VKD3D_CHECK_CFLAGS([-Wmissing-prototypes])
|
||||||
VKD3D_CHECK_CFLAGS([-Wpointer-arith])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wshadow])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wshift-overflow=2])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wtype-limits])
|
|
||||||
VKD3D_CHECK_CFLAGS([-Wunused-but-set-parameter])
|
VKD3D_CHECK_CFLAGS([-Wunused-but-set-parameter])
|
||||||
VKD3D_CHECK_CFLAGS([-Wvla])
|
VKD3D_CHECK_CFLAGS([-Wvla])
|
||||||
VKD3D_CHECK_CFLAGS([-Wwrite-strings])
|
VKD3D_CHECK_CFLAGS([-Wpointer-arith])
|
||||||
VKD3D_CHECK_CFLAGS([-Wl,--no-undefined])])
|
VKD3D_CHECK_CFLAGS([-Wl,--no-undefined])])
|
||||||
|
|
||||||
dnl Check for cross compilers
|
dnl Check for cross compilers
|
||||||
@@ -92,7 +83,7 @@ AS_IF([test "x$ac_cv_header_spirv_unified1_GLSL_std_450_h" != "xyes" \
|
|||||||
-a "x$ac_cv_header_vulkan_GLSL_std_450_h" != "xyes"],
|
-a "x$ac_cv_header_vulkan_GLSL_std_450_h" != "xyes"],
|
||||||
[AC_MSG_ERROR([GLSL.std.450.h not found.])])
|
[AC_MSG_ERROR([GLSL.std.450.h not found.])])
|
||||||
|
|
||||||
VKD3D_CHECK_VULKAN_HEADER_VERSION([228], [AC_MSG_ERROR([Vulkan headers are too old, 1.3.228 is required.])])
|
VKD3D_CHECK_VULKAN_HEADER_VERSION([139], [AC_MSG_ERROR([Vulkan headers are too old, 1.2.139 is required.])])
|
||||||
|
|
||||||
AC_CHECK_DECL([SpvCapabilityDemoteToHelperInvocationEXT],, [AC_MSG_ERROR([SPIR-V headers are too old.])], [
|
AC_CHECK_DECL([SpvCapabilityDemoteToHelperInvocationEXT],, [AC_MSG_ERROR([SPIR-V headers are too old.])], [
|
||||||
#ifdef HAVE_SPIRV_UNIFIED1_SPIRV_H
|
#ifdef HAVE_SPIRV_UNIFIED1_SPIRV_H
|
||||||
@@ -129,30 +120,10 @@ AS_IF([test "x$SONAME_LIBVULKAN" = "x"],
|
|||||||
[VKD3D_CHECK_VULKAN],
|
[VKD3D_CHECK_VULKAN],
|
||||||
[AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$SONAME_LIBVULKAN"],[Define to the shared object name of the Vulkan library.])])
|
[AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$SONAME_LIBVULKAN"],[Define to the shared object name of the Vulkan library.])])
|
||||||
|
|
||||||
AC_ARG_VAR([SONAME_LIBDXCOMPILER], [shared object name for the dxcompiler library])
|
|
||||||
AC_ARG_VAR([DXCOMPILER_LIBS], [linker flags for the dxcompiler library])
|
|
||||||
AS_IF([test "x$SONAME_LIBDXCOMPILER" = "x"],
|
|
||||||
[VKD3D_CHECK_SONAME([dxcompiler], [DxcCreateInstance], [HAVE_DXCOMPILER=yes], [HAVE_DXCOMPILER=no], [$DXCOMPILER_LIBS])],
|
|
||||||
[AC_DEFINE_UNQUOTED([SONAME_LIBDXCOMPILER],["$SONAME_LIBDXCOMPILER"],[Define to the shared object name of the dxcompiler library.])])
|
|
||||||
|
|
||||||
AS_IF([test "x$with_metal" != "xno"],
|
|
||||||
[AC_MSG_CHECKING([for Metal])]
|
|
||||||
[AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#include <Metal/Metal.h>])],
|
|
||||||
[AC_MSG_RESULT([yes])
|
|
||||||
AC_PROG_OBJC
|
|
||||||
AC_DEFINE([HAVE_METAL], [1], [Define to 1 if you have Metal.])
|
|
||||||
with_metal=yes],
|
|
||||||
[AC_MSG_RESULT([no])
|
|
||||||
AM_CONDITIONAL([am__fastdepOBJC], [false])
|
|
||||||
with_metal=no])])
|
|
||||||
AS_IF([test "x$with_ncurses" != "xno"],
|
AS_IF([test "x$with_ncurses" != "xno"],
|
||||||
[PKG_CHECK_MODULES([NCURSES], [ncurses],
|
[PKG_CHECK_MODULES([NCURSES], [ncurses],
|
||||||
[AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes],
|
[AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes],
|
||||||
[with_ncurses=no])])
|
[with_ncurses=no])])
|
||||||
AS_IF([test "x$with_opengl" != "xno"],
|
|
||||||
[PKG_CHECK_MODULES([OPENGL], [egl opengl],
|
|
||||||
[AC_DEFINE([HAVE_OPENGL], [1], [Define to 1 if you have OpenGL.]) with_opengl=yes],
|
|
||||||
[with_opengl=no])])
|
|
||||||
AS_IF([test "x$with_spirv_tools" = "xyes"],
|
AS_IF([test "x$with_spirv_tools" = "xyes"],
|
||||||
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
|
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
|
||||||
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
|
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
|
||||||
@@ -170,10 +141,7 @@ VKD3D_CHECK_FUNC([HAVE_BUILTIN_CLZ], [__builtin_clz], [__builtin_clz(0)])
|
|||||||
VKD3D_CHECK_FUNC([HAVE_BUILTIN_POPCOUNT], [__builtin_popcount], [__builtin_popcount(0)])
|
VKD3D_CHECK_FUNC([HAVE_BUILTIN_POPCOUNT], [__builtin_popcount], [__builtin_popcount(0)])
|
||||||
VKD3D_CHECK_FUNC([HAVE_BUILTIN_ADD_OVERFLOW], [__builtin_add_overflow], [__builtin_add_overflow(0, 0, (int *)0)])
|
VKD3D_CHECK_FUNC([HAVE_BUILTIN_ADD_OVERFLOW], [__builtin_add_overflow], [__builtin_add_overflow(0, 0, (int *)0)])
|
||||||
VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_and_fetch((int *)0, 0)])
|
VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_and_fetch((int *)0, 0)])
|
||||||
VKD3D_CHECK_FUNC([HAVE_SYNC_BOOL_COMPARE_AND_SWAP], [__sync_bool_compare_and_swap], [__sync_bool_compare_and_swap((int *)0, 0, 0)])
|
VKD3D_CHECK_FUNC([HAVE_SYNC_SUB_AND_FETCH], [__sync_sub_and_fetch], [__sync_sub_and_fetch((int *)0, 0)])
|
||||||
VKD3D_CHECK_FUNC([HAVE_ATOMIC_EXCHANGE_N], [__atomic_exchange_n], [__atomic_exchange_n((int *)0, 0, 0)])
|
|
||||||
AC_CHECK_FUNCS([gettid])
|
|
||||||
AC_CHECK_FUNCS([pthread_threadid_np])
|
|
||||||
|
|
||||||
dnl Makefiles
|
dnl Makefiles
|
||||||
case $host_os in
|
case $host_os in
|
||||||
@@ -193,7 +161,6 @@ AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])
|
|||||||
AM_CONDITIONAL([HAVE_WIDL], [test "x$WIDL" != "xno"])
|
AM_CONDITIONAL([HAVE_WIDL], [test "x$WIDL" != "xno"])
|
||||||
AM_CONDITIONAL([HAVE_CROSSTARGET32], [test "x$CROSSTARGET32" != "xno"])
|
AM_CONDITIONAL([HAVE_CROSSTARGET32], [test "x$CROSSTARGET32" != "xno"])
|
||||||
AM_CONDITIONAL([HAVE_CROSSTARGET64], [test "x$CROSSTARGET64" != "xno"])
|
AM_CONDITIONAL([HAVE_CROSSTARGET64], [test "x$CROSSTARGET64" != "xno"])
|
||||||
AM_CONDITIONAL([HAVE_METAL], [test "${host_os#darwin}" != "$host_os"])
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
@@ -210,10 +177,7 @@ AS_ECHO(["
|
|||||||
|
|
||||||
widl: ${WIDL}
|
widl: ${WIDL}
|
||||||
|
|
||||||
Have dxcompiler: ${HAVE_DXCOMPILER}
|
|
||||||
Have Metal: ${with_metal}
|
|
||||||
Have ncurses: ${with_ncurses}
|
Have ncurses: ${with_ncurses}
|
||||||
Have OpenGL: ${with_opengl}
|
|
||||||
Have SPIRV-Tools: ${with_spirv_tools}
|
Have SPIRV-Tools: ${with_spirv_tools}
|
||||||
Have xcb: ${HAVE_XCB}
|
Have xcb: ${HAVE_XCB}
|
||||||
|
|
||||||
|
36
demos/demo.h
36
demos/demo.h
@@ -39,42 +39,6 @@
|
|||||||
#include <vkd3d_d3d12.h>
|
#include <vkd3d_d3d12.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
#define DEMO_ASM_PUSHSECTION ".section rdata\n\t"
|
|
||||||
#define DEMO_ASM_POPSECTION ".text\n\t"
|
|
||||||
#define DEMO_ASM_OBJECT_TYPE(name)
|
|
||||||
#else
|
|
||||||
#define DEMO_ASM_PUSHSECTION ".pushsection .rodata\n\t"
|
|
||||||
#define DEMO_ASM_POPSECTION ".popsection\n\t"
|
|
||||||
#define DEMO_ASM_OBJECT_TYPE(name) ".type "name", @object\n\t"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__WIN32__) && defined(__i386__)
|
|
||||||
#define DEMO_ASM_NAME(name) "_"#name
|
|
||||||
#else
|
|
||||||
#define DEMO_ASM_NAME(name) #name
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEMO_EMBED_ASM(name, file) \
|
|
||||||
DEMO_ASM_PUSHSECTION \
|
|
||||||
".global "name"\n\t" \
|
|
||||||
DEMO_ASM_OBJECT_TYPE(name) \
|
|
||||||
".balign 8\n\t" \
|
|
||||||
name":\n\t" \
|
|
||||||
".incbin \""file"\"\n\t" \
|
|
||||||
name"_end:\n\t" \
|
|
||||||
".global "name"_size\n\t" \
|
|
||||||
DEMO_ASM_OBJECT_TYPE(name"_size") \
|
|
||||||
".balign 8\n\t" \
|
|
||||||
name"_size:\n\t" \
|
|
||||||
".int "name"_end - "name"\n\t" \
|
|
||||||
DEMO_ASM_POPSECTION
|
|
||||||
|
|
||||||
#define DEMO_EMBED(name, file) \
|
|
||||||
extern const unsigned int name##_size; \
|
|
||||||
extern const uint8_t name[]; \
|
|
||||||
__asm__(DEMO_EMBED_ASM(DEMO_ASM_NAME(name), file))
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
|
||||||
|
|
||||||
#define DEMO_KEY_UNKNOWN 0x0000
|
#define DEMO_KEY_UNKNOWN 0x0000
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
#define VK_USE_PLATFORM_XCB_KHR
|
#define VK_USE_PLATFORM_XCB_KHR
|
||||||
#define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_15
|
#define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_7
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <vkd3d.h>
|
#include <vkd3d.h>
|
||||||
#include <vkd3d_utils.h>
|
#include <vkd3d_utils.h>
|
||||||
@@ -113,9 +113,6 @@ struct demo_swapchain
|
|||||||
VkDevice vk_device;
|
VkDevice vk_device;
|
||||||
ID3D12CommandQueue *command_queue;
|
ID3D12CommandQueue *command_queue;
|
||||||
|
|
||||||
ID3D12Fence *present_fence;
|
|
||||||
unsigned long long present_count;
|
|
||||||
|
|
||||||
uint32_t current_buffer;
|
uint32_t current_buffer;
|
||||||
unsigned int buffer_count;
|
unsigned int buffer_count;
|
||||||
ID3D12Resource *buffers[1];
|
ID3D12Resource *buffers[1];
|
||||||
@@ -532,17 +529,6 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
|||||||
}
|
}
|
||||||
swapchain->buffer_count = image_count;
|
swapchain->buffer_count = image_count;
|
||||||
free(vk_images);
|
free(vk_images);
|
||||||
|
|
||||||
if (FAILED(ID3D12Device_CreateFence(d3d12_device, 0, 0, &IID_ID3D12Fence, (void **)&swapchain->present_fence)))
|
|
||||||
{
|
|
||||||
for (i = 0; i < image_count; ++i)
|
|
||||||
{
|
|
||||||
ID3D12Resource_Release(swapchain->buffers[i]);
|
|
||||||
}
|
|
||||||
free(swapchain);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
swapchain->present_count = 0;
|
|
||||||
ID3D12Device_Release(d3d12_device);
|
ID3D12Device_Release(d3d12_device);
|
||||||
|
|
||||||
ID3D12CommandQueue_AddRef(swapchain->command_queue = command_queue);
|
ID3D12CommandQueue_AddRef(swapchain->command_queue = command_queue);
|
||||||
@@ -588,12 +574,6 @@ static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
|
|||||||
present_desc.pImageIndices = &swapchain->current_buffer;
|
present_desc.pImageIndices = &swapchain->current_buffer;
|
||||||
present_desc.pResults = NULL;
|
present_desc.pResults = NULL;
|
||||||
|
|
||||||
/* Synchronize vkd3d_acquire_vk_queue() with the Direct3D 12 work
|
|
||||||
* already submitted to the command queue. */
|
|
||||||
++swapchain->present_count;
|
|
||||||
ID3D12CommandQueue_Signal(swapchain->command_queue, swapchain->present_fence, swapchain->present_count);
|
|
||||||
ID3D12Fence_SetEventOnCompletion(swapchain->present_fence, swapchain->present_count, NULL);
|
|
||||||
|
|
||||||
vk_queue = vkd3d_acquire_vk_queue(swapchain->command_queue);
|
vk_queue = vkd3d_acquire_vk_queue(swapchain->command_queue);
|
||||||
vkQueuePresentKHR(vk_queue, &present_desc);
|
vkQueuePresentKHR(vk_queue, &present_desc);
|
||||||
vkd3d_release_vk_queue(swapchain->command_queue);
|
vkd3d_release_vk_queue(swapchain->command_queue);
|
||||||
@@ -609,7 +589,6 @@ static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
ID3D12CommandQueue_Release(swapchain->command_queue);
|
ID3D12CommandQueue_Release(swapchain->command_queue);
|
||||||
ID3D12Fence_Release(swapchain->present_fence);
|
|
||||||
for (i = 0; i < swapchain->buffer_count; ++i)
|
for (i = 0; i < swapchain->buffer_count; ++i)
|
||||||
{
|
{
|
||||||
ID3D12Resource_Release(swapchain->buffers[i]);
|
ID3D12Resource_Release(swapchain->buffers[i]);
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
DEMO_EMBED(gears_hlsl, "gears.hlsl");
|
#include "gears_hlsl.h"
|
||||||
|
|
||||||
struct cxg_fence
|
struct cxg_fence
|
||||||
{
|
{
|
||||||
@@ -681,14 +681,11 @@ static void cxg_load_assets(struct cx_gears *cxg)
|
|||||||
hr = demo_create_root_signature(cxg->device, &root_signature_desc, &cxg->root_signature);
|
hr = demo_create_root_signature(cxg->device, &root_signature_desc, &cxg->root_signature);
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
|
|
||||||
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
|
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
|
||||||
NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
|
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
|
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_flat", "ps_5_0", 0, 0, &ps_flat, NULL);
|
||||||
NULL, NULL, "ps_main_flat", "ps_5_0", 0, 0, &ps_flat, NULL);
|
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
|
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_smooth", "ps_5_0", 0, 0, &ps_smooth, NULL);
|
||||||
NULL, NULL, "ps_main_smooth", "ps_5_0", 0, 0, &ps_smooth, NULL);
|
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
|
|
||||||
memset(&pso_desc, 0, sizeof(pso_desc));
|
memset(&pso_desc, 0, sizeof(pso_desc));
|
||||||
@@ -891,9 +888,6 @@ static int cxg_main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Do not trigger -Wmissing-prototypes. */
|
|
||||||
int wmain(void);
|
|
||||||
|
|
||||||
int wmain(void)
|
int wmain(void)
|
||||||
#else
|
#else
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -1,55 +0,0 @@
|
|||||||
cbuffer gear_block : register(b0)
|
|
||||||
{
|
|
||||||
float4x4 mvp_matrix;
|
|
||||||
float3x3 normal_matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vs_in
|
|
||||||
{
|
|
||||||
float4 position : POSITION;
|
|
||||||
float3 normal : NORMAL;
|
|
||||||
float3 diffuse : DIFFUSE;
|
|
||||||
float4 transform : TRANSFORM;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vs_out
|
|
||||||
{
|
|
||||||
float4 position : SV_POSITION;
|
|
||||||
float4 colour : COLOR;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vs_out vs_main(struct vs_in i)
|
|
||||||
{
|
|
||||||
const float3 l_pos = float3(5.0, 5.0, 10.0);
|
|
||||||
float3 dir, normal;
|
|
||||||
float4 position;
|
|
||||||
struct vs_out o;
|
|
||||||
float att;
|
|
||||||
|
|
||||||
position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z;
|
|
||||||
position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w;
|
|
||||||
position.zw = i.position.zw;
|
|
||||||
|
|
||||||
o.position = mul(mvp_matrix, position);
|
|
||||||
dir = normalize(l_pos - o.position.xyz / o.position.w);
|
|
||||||
|
|
||||||
normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y;
|
|
||||||
normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x;
|
|
||||||
normal.z = i.normal.z;
|
|
||||||
att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal)));
|
|
||||||
|
|
||||||
o.colour.xyz = i.diffuse.xyz * att;
|
|
||||||
o.colour.w = 1.0;
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET
|
|
||||||
{
|
|
||||||
return colour;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET
|
|
||||||
{
|
|
||||||
return colour;
|
|
||||||
}
|
|
56
demos/gears_hlsl.h
Normal file
56
demos/gears_hlsl.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
static const char gears_hlsl[] =
|
||||||
|
"cbuffer gear_block : register(b0)\n"
|
||||||
|
"{\n"
|
||||||
|
" float4x4 mvp_matrix;\n"
|
||||||
|
" float3x3 normal_matrix;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct vs_in\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 position : POSITION;\n"
|
||||||
|
" float3 normal : NORMAL;\n"
|
||||||
|
" float3 diffuse : DIFFUSE;\n"
|
||||||
|
" float4 transform : TRANSFORM;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct vs_out\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 position : SV_POSITION;\n"
|
||||||
|
" float4 colour : COLOR;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct vs_out vs_main(struct vs_in i)\n"
|
||||||
|
"{\n"
|
||||||
|
" const float3 l_pos = float3(5.0, 5.0, 10.0);\n"
|
||||||
|
" float3 dir, normal;\n"
|
||||||
|
" float4 position;\n"
|
||||||
|
" struct vs_out o;\n"
|
||||||
|
" float att;\n"
|
||||||
|
"\n"
|
||||||
|
" position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z;\n"
|
||||||
|
" position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w;\n"
|
||||||
|
" position.zw = i.position.zw;\n"
|
||||||
|
"\n"
|
||||||
|
" o.position = mul(mvp_matrix, position);\n"
|
||||||
|
" dir = normalize(l_pos - o.position.xyz / o.position.w);\n"
|
||||||
|
"\n"
|
||||||
|
" normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y;\n"
|
||||||
|
" normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x;\n"
|
||||||
|
" normal.z = i.normal.z;\n"
|
||||||
|
" att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal)));\n"
|
||||||
|
"\n"
|
||||||
|
" o.colour.xyz = i.diffuse.xyz * att;\n"
|
||||||
|
" o.colour.w = 1.0;\n"
|
||||||
|
"\n"
|
||||||
|
" return o;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET\n"
|
||||||
|
"{\n"
|
||||||
|
" return colour;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET\n"
|
||||||
|
"{\n"
|
||||||
|
" return colour;\n"
|
||||||
|
"}\n";
|
@@ -45,7 +45,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
DEMO_EMBED(triangle_hlsl, "triangle.hlsl");
|
#include "triangle_hlsl.h"
|
||||||
|
|
||||||
struct cxt_fence
|
struct cxt_fence
|
||||||
{
|
{
|
||||||
@@ -285,11 +285,9 @@ static void cxt_load_assets(struct cx_triangle *cxt)
|
|||||||
hr = demo_create_root_signature(cxt->device, &root_signature_desc, &cxt->root_signature);
|
hr = demo_create_root_signature(cxt->device, &root_signature_desc, &cxt->root_signature);
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
|
|
||||||
hr = D3DCompile(triangle_hlsl, triangle_hlsl_size, "triangle.hlsl",
|
hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
|
||||||
NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
|
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
hr = D3DCompile(triangle_hlsl, triangle_hlsl_size, "triangle.hlsl",
|
hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "ps_main", "ps_5_0", 0, 0, &ps, NULL);
|
||||||
NULL, NULL, "ps_main", "ps_5_0", 0, 0, &ps, NULL);
|
|
||||||
assert(SUCCEEDED(hr));
|
assert(SUCCEEDED(hr));
|
||||||
|
|
||||||
memset(&pso_desc, 0, sizeof(pso_desc));
|
memset(&pso_desc, 0, sizeof(pso_desc));
|
||||||
@@ -403,9 +401,6 @@ static int cxt_main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Do not trigger -Wmissing-prototypes. */
|
|
||||||
int wmain(void);
|
|
||||||
|
|
||||||
int wmain(void)
|
int wmain(void)
|
||||||
#else
|
#else
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
struct ps_in
|
|
||||||
{
|
|
||||||
float4 position : SV_POSITION;
|
|
||||||
float4 colour : COLOR;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR)
|
|
||||||
{
|
|
||||||
struct ps_in o;
|
|
||||||
|
|
||||||
o.position = position;
|
|
||||||
o.colour = colour;
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 ps_main(struct ps_in i) : SV_TARGET
|
|
||||||
{
|
|
||||||
return i.colour;
|
|
||||||
}
|
|
21
demos/triangle_hlsl.h
Normal file
21
demos/triangle_hlsl.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
static const char triangle_hlsl[] =
|
||||||
|
"struct ps_in\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 position : SV_POSITION;\n"
|
||||||
|
" float4 colour : COLOR;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR)\n"
|
||||||
|
"{\n"
|
||||||
|
" struct ps_in o;\n"
|
||||||
|
"\n"
|
||||||
|
" o.position = position;\n"
|
||||||
|
" o.colour = colour;\n"
|
||||||
|
"\n"
|
||||||
|
" return o;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"float4 ps_main(struct ps_in i) : SV_TARGET\n"
|
||||||
|
"{\n"
|
||||||
|
" return i.colour;\n"
|
||||||
|
"}\n";
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user