Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make texture compression work in release builds when no Direct3d hardware device is found. #11

Merged
merged 3 commits into from
Feb 20, 2018

Conversation

erikdahlstrom
Copy link
Contributor

No description provided.

@robertos
Copy link
Contributor

DeviceResources comes directly from the VS templates, so I didn't want to fork it.
I think the intended way to fix this is to change GLTFTextureCompressionUtils to catch the initialization failure and use the compression method that doesn't use a device:

    bool gpuCompressionSuccessful = false;

    try
    {
        DX::DeviceResources deviceResources;
        deviceResources.CreateDeviceResources();
        ComPtr<ID3D11Device> device(deviceResources.GetD3DDevice());
        DirectX::ScratchImage compressedImage;
    
        if (device != nullptr)
        {
            if (SUCCEEDED(DirectX::Compress(device.Get(), image.GetImages(), image.GetImageCount(), image.GetMetadata(), compressionFormat, DirectX::TEX_COMPRESS_DEFAULT, 0, compressedImage)))
            {
                gpuCompressionSuccessful = true;
            }
        }
    }
    catch (std::exception e) 
    { 
        // Failed to initialize device - GPU is not available 
    }

    if (!gpuCompressionSuccessful)
    {
        // Try software compression
        if (FAILED(DirectX::Compress(image.GetImages(), image.GetImageCount(), image.GetMetadata(), compressionFormat, DirectX::TEX_COMPRESS_DEFAULT, 0, compressedImage)))
        {
            throw GLTFException("Failed to compress data using software compression");
        }
    }

Copy link
Contributor

@robertos robertos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider not changing DeviceResources, but changing our use of it instead

@erikdahlstrom erikdahlstrom changed the title Use the WARP software fallback in release builds too. Fixes issue #10. Make texture compression work in release builds when no Direct3d hardware device is found. Feb 20, 2018
@erikdahlstrom
Copy link
Contributor Author

Ping, does this look ok?

@robertos
Copy link
Contributor

Thank you so much Erik!

@robertos robertos merged commit b673074 into microsoft:master Feb 20, 2018
erikdahlstrom added a commit to erikdahlstrom/glTF-Toolkit that referenced this pull request Feb 22, 2018
…ware device is found. (microsoft#11)

* Use the WARP software fallback in release builds too. Fixes issue microsoft#10.

* Revert "Use the WARP software fallback in release builds too. Fixes issue microsoft#10."

This reverts commit 5cc40ab.

* Handle lack of GPU device in GLTFTextureCompressionUtils.

Fixes issue microsoft#10.
@erikdahlstrom erikdahlstrom deleted the use_warp_fallback branch February 22, 2018 13:59
robertos pushed a commit that referenced this pull request Feb 27, 2018
* Make texture compression work in release builds when no Direct3d hardware device is found. (#11)

* Use the WARP software fallback in release builds too. Fixes issue #10.

* Revert "Use the WARP software fallback in release builds too. Fixes issue #10."

This reverts commit 5cc40ab.

* Handle lack of GPU device in GLTFTextureCompressionUtils.

Fixes issue #10.

* Update all NuGet packages to latest and fix breaking changes (#13)

* Update all NuGet packages to latest and fix breaking changes

* Update README.md

Removes version from Microsoft.glTF.CPP link

* Add share-materials flag to WindowsMRAssetConverter.

- Pack textures only once.
- Pass the flag to merger (to avoid adding the same materials again).

* Avoid adding duplicated information when sharing materials.

* Fix incorrect assumption in shared materials merger.

Lower LODs may use fewer textures due to features being removed, even if
they use the same images/textures for all that remains. Because of this
the material indices need to be adjusted for the lower LODs to be correct.

* Hopefully more robust material comparison.

* Use camelCase, rename packTextures -> processTextures.

* Fixup casing.

* No need for parser state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants