Move shaders into glsl and hlsl directories

Move `data/shaders` to `data/shaders/glsl`
Move `data/hlsl` to `data/shaders/hlsl`

Fix up shader paths in the cpp files to point to the new glsl location.

`data/shaders/hlsl/compile.py` still overwrites the glsl .spv files (for
now).

Issue: #723
This commit is contained in:
Ben Clayton 2020-05-29 16:08:53 +01:00
parent cac1d2e850
commit ca884587a4
1043 changed files with 1207 additions and 1201 deletions

View file

@ -42,18 +42,18 @@ class PerlinNoise
{
private:
uint32_t permutations[512];
T fade(T t)
{
return t * t * t * (t * (t * (T)6 - (T)15) + (T)10);
T fade(T t)
{
return t * t * t * (t * (t * (T)6 - (T)15) + (T)10);
}
T lerp(T t, T a, T b)
{
return a + t * (b - a);
T lerp(T t, T a, T b)
{
return a + t * (b - a);
}
T grad(int hash, T x, T y, T z)
T grad(int hash, T x, T y, T z)
{
// Convert LO 4 bits of hash code into 12 gradient directions
int h = hash & 15;
int h = hash & 15;
T u = h < 8 ? x : y;
T v = h < 4 ? y : h == 12 || h == 14 ? x : z;
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
@ -71,7 +71,7 @@ public:
for (uint32_t i = 0; i < 256; i++)
{
permutations[i] = permutations[256 + i] = plookup[i];
}
}
}
T noise(T x, T y, T z)
{
@ -98,7 +98,7 @@ public:
uint32_t BB = permutations[B + 1] + Z;
// And add blended results for 8 corners of the cube;
T res = lerp(w, lerp(v,
T res = lerp(w, lerp(v,
lerp(u, grad(permutations[AA], x, y, z), grad(permutations[BA], x - 1, y, z)), lerp(u, grad(permutations[AB], x, y - 1, z), grad(permutations[BB], x - 1, y - 1, z))),
lerp(v, lerp(u, grad(permutations[AA + 1], x, y, z - 1), grad(permutations[BA + 1], x - 1, y, z - 1)), lerp(u, grad(permutations[AB + 1], x, y - 1, z - 1), grad(permutations[BB + 1], x - 1, y - 1, z - 1))));
return res;
@ -111,13 +111,13 @@ class FractalNoise
{
private:
PerlinNoise<float> perlinNoise;
uint32_t octaves;
uint32_t octaves;
T frequency;
T amplitude;
T persistence;
public:
FractalNoise(const PerlinNoise<T> &perlinNoise)
FractalNoise(const PerlinNoise<T> &perlinNoise)
{
this->perlinNoise = perlinNoise;
octaves = 6;
@ -129,7 +129,7 @@ public:
T sum = 0;
T frequency = (T)1;
T amplitude = (T)1;
T max = (T)0;
T max = (T)0;
for (uint32_t i = 0; i < octaves; i++)
{
sum += perlinNoise.noise(x * frequency, y * frequency, z * frequency) * amplitude;
@ -203,7 +203,7 @@ public:
~VulkanExample()
{
// Clean up used Vulkan resources
// Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class
destroyTextureImage(texture);
@ -365,7 +365,7 @@ public:
VkBufferCreateInfo bufferCreateInfo = vks::initializers::bufferCreateInfo();
bufferCreateInfo.size = texMemSize;
bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VK_CHECK_RESULT(vkCreateBuffer(device, &bufferCreateInfo, nullptr, &stagingBuffer));
// Allocate host visible memory for data upload
@ -418,7 +418,7 @@ public:
stagingBuffer,
texture.image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1,
1,
&bufferCopyRegion);
// Change texture image layout to shader read after all mip levels have been copied
@ -552,8 +552,8 @@ public:
vertices.inputBinding.resize(1);
vertices.inputBinding[0] =
vks::initializers::vertexInputBindingDescription(
VERTEX_BUFFER_BIND_ID,
sizeof(Vertex),
VERTEX_BUFFER_BIND_ID,
sizeof(Vertex),
VK_VERTEX_INPUT_RATE_VERTEX);
// Attribute descriptions
@ -565,7 +565,7 @@ public:
VERTEX_BUFFER_BIND_ID,
0,
VK_FORMAT_R32G32B32_SFLOAT,
offsetof(Vertex, pos));
offsetof(Vertex, pos));
// Location 1 : Texture coordinates
vertices.inputAttributes[1] =
vks::initializers::vertexInputAttributeDescription(
@ -597,7 +597,7 @@ public:
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1)
};
VkDescriptorPoolCreateInfo descriptorPoolInfo =
VkDescriptorPoolCreateInfo descriptorPoolInfo =
vks::initializers::descriptorPoolCreateInfo(
static_cast<uint32_t>(poolSizes.size()),
poolSizes.data(),
@ -608,21 +608,21 @@ public:
void setupDescriptorSetLayout()
{
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
{
// Binding 0 : Vertex shader uniform buffer
vks::initializers::descriptorSetLayoutBinding(
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
VK_SHADER_STAGE_VERTEX_BIT,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
VK_SHADER_STAGE_VERTEX_BIT,
0),
// Binding 1 : Fragment shader image sampler
vks::initializers::descriptorSetLayoutBinding(
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
VK_SHADER_STAGE_FRAGMENT_BIT,
1)
};
VkDescriptorSetLayoutCreateInfo descriptorLayout =
VkDescriptorSetLayoutCreateInfo descriptorLayout =
vks::initializers::descriptorSetLayoutCreateInfo(
setLayoutBindings.data(),
static_cast<uint32_t>(setLayoutBindings.size()));
@ -639,7 +639,7 @@ public:
void setupDescriptorSet()
{
VkDescriptorSetAllocateInfo allocInfo =
VkDescriptorSetAllocateInfo allocInfo =
vks::initializers::descriptorSetAllocateInfo(
descriptorPool,
&descriptorSetLayout,
@ -651,15 +651,15 @@ public:
{
// Binding 0 : Vertex shader uniform buffer
vks::initializers::writeDescriptorSet(
descriptorSet,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
0,
descriptorSet,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
0,
&uniformBufferVS.descriptor),
// Binding 1 : Fragment shader texture sampler
vks::initializers::writeDescriptorSet(
descriptorSet,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1,
descriptorSet,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1,
&texture.descriptor)
};
@ -688,7 +688,7 @@ public:
VkPipelineColorBlendStateCreateInfo colorBlendState =
vks::initializers::pipelineColorBlendStateCreateInfo(
1,
1,
&blendAttachmentState);
VkPipelineDepthStencilStateCreateInfo depthStencilState =
@ -718,8 +718,8 @@ public:
// Load shaders
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
shaderStages[0] = loadShader(getAssetPath() + "shaders/texture3d/texture3d.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getAssetPath() + "shaders/texture3d/texture3d.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
shaderStages[0] = loadShader(getShadersPath() + "texture3d/texture3d.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getShadersPath() + "texture3d/texture3d.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
vks::initializers::pipelineCreateInfo(