I'm having problems attempting to get the debugPrintfEXT working in the shaders

It seems like I got partly working, but every time it tries to log I get this message:

Validation Layer: Validation Warning: [ UNASSIGNED-DEBUG-PRINTF ] Object 0: handle = 0x19d6337ae88, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x92394c89 | WARNING - Debug Printf message was truncated, likely due to a buffer size that was too small for the message

I’m only doing a one char test log right now untill I get it working so it shouldn’t have be a problem. I’ve also got #extension GL_EXT_debug_printf : enable enabled in the shader.

I’ve gotten the debugger setting set to:

||VkDebugUtilsMessengerCreateInfoEXT DebugInfo = {};

DebugInfo.pfnUserCallback = DebugCallBack;

Start up validation info:

VkValidationFeatureDisableEXT disabled[] = {
std::vector<const char*> ExtensionList = getRequiredExtensions();
VkInstanceCreateInfo VulkanCreateInfo = {};
VulkanCreateInfo.pApplicationInfo = &VulkanInfo;
VulkanCreateInfo.enabledExtensionCount = static_cast<uint32_t>(ExtensionList.size());
VulkanCreateInfo.ppEnabledExtensionNames = ExtensionList.data();

#ifdef NDEBUG
VulkanCreateInfo.enabledLayerCount = 0;
VulkanCreateInfo.pNext = nullptr;
VkDebugUtilsMessengerCreateInfoEXT DebugInfo;

VkValidationFeaturesEXT ValidationFeatures{};
ValidationFeatures.disabledValidationFeatureCount = 4;
ValidationFeatures.enabledValidationFeatureCount = 1;
ValidationFeatures.pEnabledValidationFeatures = enabled;
ValidationFeatures.pDisabledValidationFeatures = disabled;
ValidationFeatures.pNext = (VkDebugUtilsMessengerCreateInfoEXT*)&DebugInfo;

VulkanCreateInfo.enabledLayerCount = static_cast<unsigned int>(ValidationLayers.size());
VulkanCreateInfo.ppEnabledLayerNames = ValidationLayers.data();
VulkanCreateInfo.pNext = &ValidationFeatures;

The vk_layer_settings:

khronos_validation.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG
khronos_validation.report_flags = error,warn,perf
khronos_validation.log_filename = stdout
khronos_validation.printf_buffer_size = 1024
khronos_validation.printf_verbose = true

Was there something I missed?

Also added the compute shader code too:

This is the compute shader that I’ve attempting to log from and debug.
It’s supposed to do bone animation, but been having some problems with it which lead me to find out about the shader logger.

#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_debug_printf : enable

#include "Lighting.glsl"

struct Vertex
  vec3 Position;
	float	  Padding1;
	vec3 Normal;
	float	  Padding2;
	vec2 TexureCoord;
	vec2 Padding3;
	vec3 Tangant;
	float	  Padding4;
	vec3 BiTangant;
	float	  Padding5;
	vec4 Color;
	ivec4 BoneID ;
	vec4 BoneWeights;

layout(binding = 0, scalar) buffer Vertices
  Vertex v[];

layout(binding = 2) uniform UniformBufferObject {
	mat4 viewInverse;
	mat4 projInverse;
    mat4 model;
    mat4 view;
    mat4 proj;
    DirectionalLight dlight;
	vec3 viewPos;
	PointLight plight;
    float vertexSize;
    mat4 PVM;
    mat4 BoneTransform[100];
    float timer;
} ubo;
layout(binding = 5) buffer Transform { mat4 Transform; } MeshTransform[];

layout(push_constant) uniform MeshInfo
	uint MeshID;
	uint ModelID;
	uint MaterialID;
} Mesh;

void main()

  Vertex v0 = vertices.v[gl_GlobalInvocationID.x];

  mat4 BoneTransform = mat4(1.0f);
  BoneTransform =  ubo.BoneTransform[v0.BoneID[0]] * v0.BoneWeights[0];
  BoneTransform += ubo.BoneTransform[v0.BoneID[1]] * v0.BoneWeights[1];
  BoneTransform += ubo.BoneTransform[v0.BoneID[2]] * v0.BoneWeights[2];
  BoneTransform += ubo.BoneTransform[v0.BoneID[3]] * v0.BoneWeights[3];
  vec4 BonePosition = BoneTransform * vec4(v0.Position, 1.0);

  v0.Position = vec3(ubo.model * MeshTransform[0].Transform * BonePosition);
  v0.Normal = normalize(transpose(inverse(mat3(ubo.model * MeshTransform[0].Transform * BoneTransform))) * v0.Normal);
	v0.Color = vec4(v0.BoneID.xyz, 1.0f);
  vertices.v[gl_GlobalInvocationID.x] = v0;

Your shader print will run for every invocation, probably resulting in more chars printed than the buffer can hold.

Try to either increase the printf_buffer_size, lower the verbosity level of your debug callback, or don’t printf from your shader on every invocation and limit the printfs by using e.g. an if-statement.

hmm, tried increasing the buffer size to a megabyte. Tried loading something small like a cube with 24 vertices and put the test debugPrintfEXT in the vertex shader. Also put a break point at the end of the first frame. The debugger gave me the same message.

Try to lower the verbosity of the messages. VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT will output lots of information, and will cause the buffer truncation. I have just verified this myself.

Okay, I made use a basic vulkan templete using vulkantutorial and put in in the shader printf settings and still got the same error.

I got it working.

Look like I just needed to add VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT to the VkDebugUtilsMessengerCreateInfoEXT.messageSeverity.