0

As far as I understand, the scalar layout qualifier in vulkan GLSL should allow a simple array of vec3 values to work, apparently with out any physical device features to be specified. I've tried with and with out specifying scalar layout features like so:

VkPhysicalDeviceScalarBlockLayoutFeatures layoutfeatures = {};
layoutfeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES;
layoutfeatures.scalarBlockLayout = VK_TRUE;
VkPhysicalDeviceFeatures2 features2 = {};
features2.features = m_required_features;
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
features2.pNext = &layoutfeatures;

VkDeviceCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
create_info.queueCreateInfoCount = static_cast<uint32_t>(queue_create_infos.size());
create_info.pQueueCreateInfos = queue_create_infos.data();
create_info.enabledExtensionCount = static_cast<uint32_t>(enabled_extensions_names.size());
create_info.ppEnabledExtensionNames = enabled_extensions_names.data();
create_info.pEnabledFeatures = &features2 .features;
create_info.pNext = &features2 ;
create_info.flags = flags;
VkDevice device;
VUL_EXCEPT_RESULT(vkCreateDevice(physical_device, &create_info, pAllocator, &device));

but to no avail. I'm getting strange spec invalidation errors.

here's example code:

#version 450
#extension GL_EXT_scalar_block_layout: require

#define WORKGROUP_SIZE 128
layout (local_size_x = WORKGROUP_SIZE, local_size_y = 1, local_size_z = 1) in;
layout(scalar, binding = 3) buffer MyBufferBlock{
    vec3 example_array[];
};


void main(){
 example_array[gl_GlobalInvocationID.x] = 0.0;
}

and I get the following SPIR-V validation error:

"example.exe"
ERROR : SPEC_INVALIDATION - Message ID Number 7060244, Message ID String UNASSIGNED-CoreValidation-Shader-InconsistentSpirv:
Validation Error: [ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object 0: handle = 0x6543e40, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x6bbb14 | SPIR-V module not valid: Structure id 500 decorated as BufferBlock for variable in Uniform storage class must follow relaxed storage buffer layout rules: member 0 contains an array with stride 12 not satisfying alignment to 16
  %MyBufferBlock = OpTypeStruct %_runtimearr_v3float

First I don't understand why it is trying to call out my buffer as a uniform? and obviuosly I'm still confused on how this is at all a spec violation.

Krupip
  • 4,404
  • 2
  • 32
  • 54
  • 1
    "*apparently with out any physical device features to be specified*" How do you figure that? `scalarBlockLayout` is a specific 1.2 feature, and the spec clearly says you have to turn it on to use that feature. – Nicol Bolas Apr 29 '20 at 20:15
  • @NicolBolas Hence why I said apparently, because other people have managed to use it with out it. Case in point, my link. I currently have it enabled (using the method outlined above unless there is anything else I need to do with device features). Same error. – Krupip Apr 29 '20 at 20:19
  • You did check to see if the feature was available, right? Also, "*other people have managed to use it with out it.*" I don't see anywhere in that link that explicitly states that the person *didn't* activate the feature. He just didn't talk about it. – Nicol Bolas Apr 29 '20 at 21:02
  • 1
    Because Vulkan doesn't do error checking for you unless you add validation layers, it's possible someone else did something illegal here and it just happened to work. – Andrea May 03 '20 at 12:42

0 Answers0