Commit Graph

364 Commits

Author SHA1 Message Date
Philip Rebohle 36bdc02a05 include: Introduce void_ptr_offset.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle bea196e449 vkd3d-shader: Declare offset buffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Joshua Ashton ac2456b01f vkd3d-shader: Implement double data type
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton 4fb3e277f1 vkd3d: Remove VKD3D_RESOURCE_PRESENT_STATE_TRANSITION
All this flag does is make resource creation fail.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-22 09:30:24 +02:00
Hans-Kristian Arntzen d7e9713c4c vkd3d: Add external API to perform initial transition.
Relevant for swapchain since a swapchain resource can be presented right
away without ever having been touched by an API call.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Philip Rebohle 367cda017f vkd3d-shader: Implement resource declarations with raw SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle b82bbe265e vkd3d: Pass storage buffer alignment to shader compiler.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Hans-Kristian Arntzen 85dbb6c569 vkd3d-shader: Support StorageImageReadWithoutFormat.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 14:55:24 +02:00
Hans-Kristian Arntzen 3f1132ee8c vkd3d: Add support for InterlockedIncrement64.
To be used for cookies. Works on 32-bit as well, compiler emits 8b CAS loop
for us.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 12:46:07 +02:00
Hans-Kristian Arntzen 4dff80661a vkd3d: Rewrite initial resource state tracking.
For correctness, we will need to defer any initial resource state
handling to the queue timeline. Here, we will build an UNDEFINED ->
common layout barrier if (and only if):

- The resource is marked to care about initial layout transition.
- We are the first queue thread to observe that initial_transition
  member is 1 (atomic exchange).
- The first use of the resource was not marked to be a discard.
  E.g., if the first use of the resource is an alias barrier, we must
  not emit an early barrier. The only we should do here is to clear the
  initial_transition member, and leave it like that.

A command list maintains a list of d3d12_resources which *might* need a
transition. For the first frame a resource is used (or so), it will not
have the flag cleared yet, so multiple command lists might add the
d3d12_resource to its own transition list. This is fine, as the queue
will resolve it.

If multiple queues see the same initial transition, there might be
shenanigans, but the application must ensure there is either a
submission boundary or fence boundary between the uses. Any initial
layout transition will only be submitted after a Wait() is observed, as
submission of the transition command buffer will be in-order with other
submissions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-08 14:30:50 +02:00
Joshua Ashton a991fddeeb build: Use `-fvisibility=hidden` and define exports manually
When building natively on Windows we use dllexport/dllimport for vkd3d/vkd3d_utils public exports.

When building natively on Linux we simply make those visibility default.

Nothing changes for standalone here.

Closes #152

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:44:10 +02:00
Joshua Ashton be2c0c1f1e include: Remove DECLSPEC_HIDDEN from headers
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:44:10 +02:00
Hans-Kristian Arntzen 9d36ab59d6 vkd3d: Add support for a shader debug ring.
Will allow replaced shaders to emit debug messages to a buffer.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-29 15:00:36 +02:00
Hans-Kristian Arntzen 250357c998 debug: Integrate automatic RenderDoc capturing.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-22 12:44:18 +02:00
Hans-Kristian Arntzen 586f002536 vkd3d-shader: Add shader replacement.
For debugging purposes, it can be extremely useful to be able to
pinpoint and replace specific shaders for testing hypotheses.

To make this practical, change the shader dumping to use hashes rather
than monotonically incrementing indices.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen f473370678 vkd3d-shader: Add hash function for shader blobs.
Simple FNV-1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen b93963b6ce debug: Log thread ID as well.
For multi-threaded apps, this is vital to make any sense of the log.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Philip Rebohle 3002d52ed4 include: Define D3D12 error codes as necessary.
These are technically supposed to be defined in winerror.h,
but current MinGW headers do not support these yet.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle c06e2bdc83 vkd3d: Introduce vkd3d_wcslen.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Hans-Kristian Arntzen 254868a326 vkd3d: Enable pthread workaround paths on MinGW as well.
winpthread is slow on Wine as it requires OS synchronization
objects, which involves wineserver.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 09:34:26 +02:00
Hans-Kristian Arntzen 7d8ab2fb06 vkd3d: Replace CS with SRW.
On Wine, this is more efficient as it can use futex paths.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 09:34:26 +02:00
Hans-Kristian Arntzen 01a7ec6310 tests: Use fflush()
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Philip Rebohle 0303c396bc vkd3d: Add float_bits_to_uint32.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 50eb972c15 include: Add hash map implementation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 40764d82ef vkd3d-shader: Introduce VKD3D_SHADER_BINDING_FLAG_RAW_VA.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Hans-Kristian Arntzen e3c1b66aed common: Add a simple profiling module.
Works by mapping a memory block on disk, and then we simply increment
u64s. The caller code only needs to use VKD3D_REGION_{DECL,BEGIN,END}
macros.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 7b0345a149 vkd3d-shader: Add way to scan for expected patch vertex count from HS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen c8bbed15d7 vkd3d: Implement 32-bit bitmask iteration.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 66b252e08f vkd3d: Remove reliance on HAVE_BUILTIN_CTZLL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 1f2499f64a vkd3d: Add 32-bit bitmask iteration with scanning.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 8743577ca5 vkd3d: Add MSVC path for pthread_once_t.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen 7bccab7427 debug: Re-introduce different debug channels.
vkd3d-shader is currently kinda buggy and crashes when you try to trace
DXBC. This used to never be run since it was guarded by
VKD3D_SHADER_DEBUG, but with the move to a static build we merged all
debug logging under VKD3D_DEBUG. Reintroduce different debug channels in
a way that is compatible with a statically linked vkd3d.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 14:18:15 +02:00
Hans-Kristian Arntzen 0c59c30e08 vkd3d: Fix tzcnt64 on MSVC 32-bit and 64-bit.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-07 16:31:29 +01:00
Joshua Ashton 9c105a78a9 vkd3d: Implement swapchain and swapchain factory
Needed for standalone D3D12.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton cb4fcd5a98 include: Replace MinGW hack with Win32 platform header
Replace this hack with a more versatile one that works for multiple compilation objects.

Consolidates this hack across all the code bases (soon to be used in a D3D12 standalone patch)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton e24914b11f include: Pull in Win32 Vulkan exts when building for Win32
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton fdcf33ff47 vkd3d-shader: Fix incorrect enum being used for tesselator partitioning
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 15:42:41 +02:00
Joshua Ashton d709fd3306 vkd3d: Add vkd3d_atomic_uint32_{dec, inc}rement helper
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 45d4296a54 vkd3d: Rename vkd3d_uint32_atomic to vkd3d_atomic_uint32
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 033f76e3ae vkd3d: Define our own memory orders
We shouldn't potentially override stuff in the std library and this allows us to map directly to __ATOMIC_* memory orders which is more correct.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 25f6e1d0a9 vkd3d: Use __atomic builtins instead of stdatomic
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 26c9dc90f4 vkd3d: Implement sequential consistency on MSVC
Also optimize and reduce unnecessary barriers.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 4c819baad3 vkd3d: Use pthread reimplementation only on MSVC
We can use pthreads properly under MinGW
2020-06-24 15:27:22 +02:00
Joshua Ashton fb02f28c41 vkd3d: Don't redefine InterlockedIncrement under MinGW
Fixes compiler warnings

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:27:22 +02:00
Joshua Ashton 4521b253dd vkd3d: Toss VKD3D_DEBUG_ENV_NAME
Creates linking problems if we want to build vkd3d-shader statically given this links back to something in vkd3d-common.

We don't need this distinction anyways...

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:18:56 +02:00
Hans-Kristian Arntzen 2b7ef38248 Revert "vkd3d: make spinlock_t atomic to make clang happy"
This reverts commit 7b1dce2667.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-24 13:40:03 +02:00
Georg Lehmann 7b1dce2667 vkd3d: make spinlock_t atomic to make clang happy
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-06-24 13:26:31 +02:00
Joshua Ashton 8c216e637c build: Add Meson build system
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton 45f9836c60 vkd3d: Eliminate config.h
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton 1f266cc16b vkd3d: Eliminate HAVE_PTHREAD_H
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00