Skip to content

Vulkan driver doesnt draw when there are many uniform matrices #545

@rds1983

Description

@rds1983

Please, see the attached sample.
It tries to draw a 2d image using following shader:

//-----------------------------------------------------------------------------
// SpriteEffect.fx
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------

#include "Macros.fxh"


DECLARE_TEXTURE(Texture, 0);


BEGIN_CONSTANTS
MATRIX_CONSTANTS
    float4x4 MatrixTransform;
    float4x4 OtherTransforms[128];
    int4 OtherTransformsIndices;
END_CONSTANTS


void SpriteVertexShader(inout float2 texCoord : TEXCOORD0,
                        inout float4 position : SV_Position)
{
    position = mul(position, MatrixTransform);
	
	position = mul(position, OtherTransforms[OtherTransformsIndices.x]);
	position = mul(position, OtherTransforms[OtherTransformsIndices.y]);
	position = mul(position, OtherTransforms[OtherTransformsIndices.z]);
	position = mul(position, OtherTransforms[OtherTransformsIndices.w]);
}


float4 SpritePixelShader(float2 texCoord : TEXCOORD0) : SV_Target0
{
    return tex2D(TextureSampler, texCoord);
}

TECHNIQUE(Default, SpriteVertexShader, SpritePixelShader);

Which is pretty much copy of the original SpriteEffect. The only difference is that it processes input position by OtherTransforms.
However all those matrices are set to Identity in the C# part of the sample, so they shouldn't affect the end result.

Unfortunately it draws nothing with the default Vulkan driver:
Image

But works correctly when using D311 or OpenGL drivers:
Image

Full Sample: ManyMatricesTest.zip

OS: Windows 11
Latest FNA 25.10 from the master branch
Latest fnalibs downloaded from fnalibs-daily at 15.10.2025

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions