|
24 | 24 | #define AMD_TRESSFX_H |
25 | 25 |
|
26 | 26 | #include <d3d11.h> |
| 27 | +#ifdef VULKAN |
| 28 | +#include <vulkan\vulkan.h> |
| 29 | +#endif |
| 30 | + |
27 | 31 | #include <DirectXMath.h> |
28 | 32 |
|
29 | 33 | #define AMD_TRESSFX_VERSION_MAJOR 3 |
|
75 | 79 | #define IDSRV_HAIR_FRAGMENT_COLORS 14 |
76 | 80 | #define IDSRV_HAIR_ACCUM_INV_ALPHA 15 |
77 | 81 |
|
| 82 | +#define IDSRV_CONSTANTS_BUFFER 16 |
| 83 | +#define IDSRV_ATOMIC_COUNTER_BUFFER 17 |
| 84 | +#define IDSRV_NOISE_SAMPLER 18 |
| 85 | +#define IDSRV_SHADOW_SAMPLER 19 |
| 86 | + |
| 87 | +#define IDSRV_HAIR_PREVIOUS_VERTEX_POSITIONS 20 |
| 88 | +#define IDSRV_HAIR_VERTEX_INITIAL_POSITIONS 21 |
| 89 | +#define IDSRV_HAIR_STRAND_TYPE 22 |
| 90 | +#define IDSRV_HAIR_GLOBAL_ROTATION 23 |
| 91 | +#define IDSRV_HAIR_LOCAL_REF_VEC 24 |
| 92 | +#define IDSRV_HAIR_ROOT_OFFSET 25 |
| 93 | +#define IDSRV_HAIR_LENGTH 26 |
| 94 | +#define IDSRV_HEAD_TRANSFORM 27 |
78 | 95 |
|
79 | 96 | #if defined(DEBUG) || defined(_DEBUG) |
80 | 97 | #define AMD_TRESSFX_DEBUG 1 |
@@ -167,10 +184,18 @@ struct TressFX_HairBlob |
167 | 184 |
|
168 | 185 | struct TressFX_SceneMesh |
169 | 186 | { |
| 187 | +#ifndef VULKAN |
170 | 188 | ID3D11ShaderResourceView* pMeshVertices; // untransformed vertices |
| 189 | +#else |
| 190 | + VkBufferView pMeshVertices; // untransformed vertices |
| 191 | +#endif |
171 | 192 | unsigned numMeshes; // number of meshes |
172 | 193 | unsigned* meshOffsets; // offset to the start of each mesh |
| 194 | +#ifndef VULKAN |
173 | 195 | ID3D11ShaderResourceView* pTransformedVerts; // transformed vertices |
| 196 | +#else |
| 197 | + VkBufferView pTransformedVerts; // untransformed vertices |
| 198 | +#endif |
174 | 199 | }; |
175 | 200 |
|
176 | 201 | struct TressFX_HairTransform |
@@ -227,32 +252,80 @@ struct TressFX_Desc |
227 | 252 | // Buffer of transformations (one transform per strand) for hair skinning |
228 | 253 | // This UAV is used as a structured buffer where each element is a TressFX_HairTransform. |
229 | 254 | // The number of elements in the buffer is numTotalHairStrands. |
| 255 | +#ifndef VULKAN |
230 | 256 | ID3D11UnorderedAccessView* pSkinningTransformationsUAV; |
| 257 | +#else |
| 258 | + VkBufferView pSkinningTransformationsUAV; |
| 259 | +#endif |
231 | 260 |
|
232 | 261 | // hair shadow map |
| 262 | +#ifndef VULKAN |
233 | 263 | ID3D11ShaderResourceView* pHairShadowMapSRV; |
| 264 | +#else |
| 265 | + VkImageView pHairShadowMapSRV; |
| 266 | +#endif |
234 | 267 |
|
| 268 | +#ifndef VULKAN |
235 | 269 | ID3D11Device* pd3dDevice; |
236 | 270 | ID3D11DeviceContext* pd3dDeviceContext; |
237 | 271 | ID3D11ShaderResourceView* pd3dDepthSRV; |
238 | 272 | ID3D11RenderTargetView* pd3dOutputRTV; |
| 273 | +#else |
| 274 | + VkDevice pvkDevice; |
| 275 | + uint32_t memoryIndexDeviceLocal; |
| 276 | + uint32_t memoryIndexHostVisible; |
| 277 | + VkImageView pvkDepthSRV; |
| 278 | + uint32_t maxConstantBuffers; |
| 279 | + VkFormat depthStencilFormat; |
| 280 | + VkFormat colorFormat; |
| 281 | +#endif // !VULKAN |
239 | 282 | }; |
240 | 283 |
|
241 | 284 | extern "C" |
242 | 285 | { |
243 | 286 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_GetVersion(uint* major, uint* minor, uint* patch); |
244 | | - AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Initialize(TressFX_Desc & desc); |
| 287 | +#ifdef VULKAN |
| 288 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Initialize( |
| 289 | + TressFX_Desc &desc, VkImageView depthTexture, VkImageView colorTexture, |
| 290 | + VkCommandBuffer commandBuffer, VkDeviceMemory scratchMemory, |
| 291 | + VkBuffer scratchBuffer, size_t &offsetInScratchBuffer); |
| 292 | +#else |
| 293 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Initialize(TressFX_Desc &desc); |
| 294 | +#endif |
245 | 295 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_LoadRawAsset(TressFX_Desc & desc, const TressFX_GuideFollowParams& guideFollowParams, TressFX_HairBlob *pRawHairBlob); |
| 296 | +#ifndef VULKAN |
246 | 297 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_LoadProcessedAsset(TressFX_Desc & desc, TressFX_HairBlob *pHairBlob, TressFX_SceneMesh *sceneMesh, ID3D11ShaderResourceView *pTextureSRV); |
247 | 298 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_CreateProcessedAsset(TressFX_Desc & desc, TressFX_HairBlob **ppHairBlob, TressFX_SceneMesh *sceneMesh, ID3D11ShaderResourceView *pTextureSRV); |
248 | 299 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Begin(TressFX_Desc & desc); |
| 300 | +#else |
| 301 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_LoadProcessedAsset( |
| 302 | + TressFX_Desc &desc, TressFX_HairBlob *pHairBlob, |
| 303 | + TressFX_SceneMesh *sceneMesh, VkImageView pTextureSRV, |
| 304 | + VkCommandBuffer uploadCmdBuffer, |
| 305 | + VkBuffer scratchBuffer, VkDeviceMemory scratchMemory); |
| 306 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_CreateProcessedAsset( |
| 307 | + TressFX_Desc &desc, TressFX_HairBlob **ppHairBlob, |
| 308 | + TressFX_SceneMesh *sceneMesh, VkImageView pTextureSRV, |
| 309 | + VkCommandBuffer uploadCmdBuffer, |
| 310 | + VkBuffer scratchBuffer, VkDeviceMemory scratchMemory); |
| 311 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Begin(TressFX_Desc & desc, uint32_t uniformBufferIndex); |
| 312 | +#endif |
249 | 313 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_End(TressFX_Desc & desc); |
250 | 314 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_GenerateTransforms(TressFX_Desc & desc, TressFX_SceneMesh &sceneMesh); |
251 | 315 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_ApplyRigidTransforms(TressFX_Desc & desc); |
| 316 | +#ifndef VULKAN |
252 | 317 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Simulate(TressFX_Desc & desc, float elapsedTime); |
253 | 318 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_RenderShadowMap(TressFX_Desc & desc); |
254 | 319 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Render(TressFX_Desc & desc); |
255 | | - AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Resize(TressFX_Desc & desc); |
| 320 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Resize(TressFX_Desc &desc); |
| 321 | +#else |
| 322 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Simulate(TressFX_Desc & desc, VkCommandBuffer commandBuffer, float elapsedTime, uint32_t uniformBufferIndex); |
| 323 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_RenderShadowMap(TressFX_Desc & desc, VkCommandBuffer commandBuffer, uint32_t uniformBufferIndex); |
| 324 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE |
| 325 | + TressFX_Render(TressFX_Desc &desc, VkCommandBuffer commandBuffer, uint32_t uniformBufferIndex); |
| 326 | + AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE |
| 327 | + TressFX_Resize(TressFX_Desc &desc, uint32_t texture_memory_index); |
| 328 | +#endif |
256 | 329 | AMD_TRESSFX_DLL_API TRESSFX_RETURN_CODE TressFX_Release(TressFX_Desc & desc); |
257 | 330 | } |
258 | 331 |
|
|
0 commit comments