|
40 | 40 | namespace Diligent |
41 | 41 | { |
42 | 42 |
|
| 43 | +#if D3D11_SUPPORTED |
| 44 | +int64_t GetNativeTextureFormatD3D11(TEXTURE_FORMAT TexFormat); |
| 45 | +TEXTURE_FORMAT GetTextureFormatFromNativeD3D11(int64_t NativeFormat); |
| 46 | +#endif |
| 47 | + |
| 48 | +#if D3D12_SUPPORTED |
| 49 | +int64_t GetNativeTextureFormatD3D12(TEXTURE_FORMAT TexFormat); |
| 50 | +TEXTURE_FORMAT GetTextureFormatFromNativeD3D12(int64_t NativeFormat); |
| 51 | +#endif |
| 52 | + |
| 53 | +#if GL_SUPPORTED || GLES_SUPPORTED |
| 54 | +int64_t GetNativeTextureFormatGL(TEXTURE_FORMAT TexFormat); |
| 55 | +TEXTURE_FORMAT GetTextureFormatFromNativeGL(int64_t NativeFormat); |
| 56 | +#endif |
| 57 | + |
| 58 | +#if VULKAN_SUPPORTED |
| 59 | +int64_t GetNativeTextureFormatVk(TEXTURE_FORMAT TexFormat); |
| 60 | +TEXTURE_FORMAT GetTextureFormatFromNativeVk(int64_t NativeFormat); |
| 61 | +#endif |
| 62 | + |
| 63 | +#if WEBGPU_SUPPORTED |
| 64 | +int64_t GetNativeTextureFormatWebGPU(TEXTURE_FORMAT TexFormat); |
| 65 | +TEXTURE_FORMAT GetTextureFormatFromNativeWebGPU(int64_t NativeFormat); |
| 66 | +#endif |
| 67 | + |
43 | 68 | void CreateUniformBuffer(IRenderDevice* pDevice, |
44 | 69 | Uint64 Size, |
45 | 70 | const Char* Name, |
@@ -540,6 +565,85 @@ IBufferView* GetBufferDefaultUAV(IObject* pBuffer) |
540 | 565 | return GetDefaultUAV(static_cast<IBuffer*>(pBuffer)); |
541 | 566 | } |
542 | 567 |
|
| 568 | +#if !WEBGPU_SUPPORTED |
| 569 | +const char* GetWebGPUEmulatedArrayIndexSuffix(IShader* pShader) |
| 570 | +{ |
| 571 | + return nullptr; |
| 572 | +} |
| 573 | +#endif |
| 574 | + |
| 575 | +int64_t GetNativeTextureFormat(TEXTURE_FORMAT TexFormat, RENDER_DEVICE_TYPE DeviceType) |
| 576 | +{ |
| 577 | + switch (DeviceType) |
| 578 | + { |
| 579 | +#if D3D11_SUPPORTED |
| 580 | + case RENDER_DEVICE_TYPE_D3D11: |
| 581 | + return GetNativeTextureFormatD3D11(TexFormat); |
| 582 | +#endif |
| 583 | + |
| 584 | +#if D3D12_SUPPORTED |
| 585 | + case RENDER_DEVICE_TYPE_D3D12: |
| 586 | + return GetNativeTextureFormatD3D12(TexFormat); |
| 587 | +#endif |
| 588 | + |
| 589 | +#if GL_SUPPORTED || GLES_SUPPORTED |
| 590 | + case RENDER_DEVICE_TYPE_GL: |
| 591 | + case RENDER_DEVICE_TYPE_GLES: |
| 592 | + return GetNativeTextureFormatGL(TexFormat); |
| 593 | +#endif |
| 594 | + |
| 595 | +#if VULKAN_SUPPORTED |
| 596 | + case RENDER_DEVICE_TYPE_VULKAN: |
| 597 | + return GetNativeTextureFormatVk(TexFormat); |
| 598 | +#endif |
| 599 | + |
| 600 | +#if WEBGPU_SUPPORTED |
| 601 | + case RENDER_DEVICE_TYPE_WEBGPU: |
| 602 | + return GetNativeTextureFormatWebGPU(TexFormat); |
| 603 | +#endif |
| 604 | + |
| 605 | + default: |
| 606 | + UNSUPPORTED("Unsupported device type"); |
| 607 | + return 0; |
| 608 | + } |
| 609 | +} |
| 610 | + |
| 611 | +TEXTURE_FORMAT GetTextureFormatFromNative(int64_t NativeFormat, RENDER_DEVICE_TYPE DeviceType) |
| 612 | +{ |
| 613 | + switch (DeviceType) |
| 614 | + { |
| 615 | +#if D3D11_SUPPORTED |
| 616 | + case RENDER_DEVICE_TYPE_D3D11: |
| 617 | + return GetTextureFormatFromNativeD3D11(NativeFormat); |
| 618 | +#endif |
| 619 | + |
| 620 | +#if D3D12_SUPPORTED |
| 621 | + case RENDER_DEVICE_TYPE_D3D12: |
| 622 | + return GetTextureFormatFromNativeD3D12(NativeFormat); |
| 623 | +#endif |
| 624 | + |
| 625 | +#if GL_SUPPORTED || GLES_SUPPORTED |
| 626 | + case RENDER_DEVICE_TYPE_GL: |
| 627 | + case RENDER_DEVICE_TYPE_GLES: |
| 628 | + return GetTextureFormatFromNativeGL(NativeFormat); |
| 629 | +#endif |
| 630 | + |
| 631 | +#if VULKAN_SUPPORTED |
| 632 | + case RENDER_DEVICE_TYPE_VULKAN: |
| 633 | + return GetTextureFormatFromNativeVk(NativeFormat); |
| 634 | +#endif |
| 635 | + |
| 636 | +#if WEBGPU_SUPPORTED |
| 637 | + case RENDER_DEVICE_TYPE_WEBGPU: |
| 638 | + return GetTextureFormatFromNativeWebGPU(NativeFormat); |
| 639 | +#endif |
| 640 | + |
| 641 | + default: |
| 642 | + UNSUPPORTED("Unsupported device type"); |
| 643 | + return TEX_FORMAT_UNKNOWN; |
| 644 | + } |
| 645 | +} |
| 646 | + |
543 | 647 | } // namespace Diligent |
544 | 648 |
|
545 | 649 |
|
@@ -616,4 +720,14 @@ extern "C" |
616 | 720 | { |
617 | 721 | return Diligent::GetWebGPUEmulatedArrayIndexSuffix(pShader); |
618 | 722 | } |
| 723 | + |
| 724 | + int64_t Diligent_GetNativeTextureFormat(Diligent::TEXTURE_FORMAT TexFormat, Diligent::RENDER_DEVICE_TYPE DeviceType) |
| 725 | + { |
| 726 | + return Diligent::GetNativeTextureFormat(TexFormat, DeviceType); |
| 727 | + } |
| 728 | + |
| 729 | + Diligent::TEXTURE_FORMAT Diligent_GetTextureFormatFromNative(int64_t NativeFormat, Diligent::RENDER_DEVICE_TYPE DeviceType) |
| 730 | + { |
| 731 | + return Diligent::GetTextureFormatFromNative(NativeFormat, DeviceType); |
| 732 | + } |
619 | 733 | } |
0 commit comments