Skip to content

Prevent typeless textures from creating srv / rtv on initialization#3095

Closed
johang88 wants to merge 4052 commits into
stride3d:masterfrom
johang88:typeless-srv-rtv
Closed

Prevent typeless textures from creating srv / rtv on initialization#3095
johang88 wants to merge 4052 commits into
stride3d:masterfrom
johang88:typeless-srv-rtv

Conversation

@johang88

Copy link
Copy Markdown
Contributor

PR Details

DirectX 11 does not allow Shader Resource Views or Render Target Views to be created for typeless textures. This change prevents their creation upon texture initialization, which would have given an exception when NativeDevice.CreateShaderResourceView / NativeDevice.CreateRenderTargetView were called. Users can then create views in their desired format using ToTextureView.

Example usage from when I had to interpret the same texture as both SRgb and non SRgb, typeless is required here as creating a non srgb view from an srgb texture is not allowed.

        _stagingDiffuse = Texture.New2D(graphicsDevice, padded, padded,
            PixelFormat.R8G8B8A8_Typeless,
            TextureFlags.RenderTarget | TextureFlags.ShaderResource);

        _stagingDiffuseTargetView = _stagingDiffuse.ToTextureView(new()
        {
            Flags = TextureFlags.RenderTarget,
            Format = PixelFormat.R8G8B8A8_UNorm_SRgb,
            Type = ViewType.Single
        });

        _stagingDiffuseCompressView = _stagingDiffuse.ToTextureView(new()
        {
            Flags = TextureFlags.ShaderResource,
            Format = PixelFormat.R8G8B8A8_UNorm,
            Type = ViewType.Single
        });

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

* Add a way to compare COM pointers for equality.
* Small cleanup
* Sealed description classes. They are rarely derived
* Also improve and expand upon ComPtrHelpers for D3D12
* Also removed ColorHelper. It was only ever used in the old D3D12
* Also separates the allocators and pools to separate files
* Also small rewrite to CompiledCommandList
* So it is equivalent to VertexBufferBinding, which already has
* Also make it IEquatable, same as VertexBufferBinding
* GraphicsException is the base of all exceptions for Stride.Graphics
* GraphicsDeviceException is now the base exception for when GraphicsDevice.Status is the culprit
xen2 and others added 23 commits March 14, 2026 02:13
* feat-add-2d-platformer-template

* various coding convention fixed for PR

* removed win and refactored animation code

* additional best practices like required fields

* File names refactored

* refactor file content from _2DX to Platformer2D

* fix: Project paths after rename operation

* fix: Required references

* chore: Minor nullable-related cleanup

* chore: Remove unnecessary sfx stop call

---------

Co-authored-by: Eideren <contact@eideren.com>
* Fixed null checking in IndexBufferBinding equals operator

* Update sources/engine/Stride.Graphics/IndexBufferBinding.cs

Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>

---------

Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>
@xen2

xen2 commented Mar 21, 2026

Copy link
Copy Markdown
Member

Probably we should do the same for D3D12 (and maybe Vulkan if it works the same)?

@johang88

Copy link
Copy Markdown
Contributor Author

Good point, I'll have to check how they behave.

@xen2
xen2 force-pushed the master branch 2 times, most recently from ab329f3 to 482bd28 Compare April 16, 2026 07:56
@xen2 xen2 closed this Jul 16, 2026
@xen2

xen2 commented Jul 17, 2026

Copy link
Copy Markdown
Member

👋 Apologies for the noise here.

This PR was closed unintentionally by a bad force-push to master on my side, which auto-closed a batch of PRs. GitHub won't let me (or you) reopen it, since the close is pinned to the now-rewritten commit.

I've contacted GitHub Support to try reopening these in bulk, but no guarantees. If this change is still relevant, it's a good opportunity to sync your branch with the latest master and open a fresh PR (your code is intact).

Sorry again for the disruption! 🙏

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.