Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ static void demo_prepare_texture_buffer(struct demo *demo, const char *filename,

static void demo_prepare_texture_image(struct demo *demo, const char *filename, struct texture_object *tex_obj,
VkImageTiling tiling, VkImageUsageFlags usage, VkFlags required_props) {
const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM;
const VkFormat tex_format = VK_FORMAT_R8G8B8A8_SRGB;
int32_t tex_width;
int32_t tex_height;
VkResult U_ASSERT_ONLY err;
Expand Down Expand Up @@ -1813,7 +1813,7 @@ static void demo_destroy_texture(struct demo *demo, struct texture_object *tex_o
}

static void demo_prepare_textures(struct demo *demo) {
const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM;
const VkFormat tex_format = VK_FORMAT_R8G8B8A8_SRGB;
VkFormatProperties props;
uint32_t i;

Expand Down Expand Up @@ -1870,8 +1870,8 @@ static void demo_prepare_textures(struct demo *demo) {
demo_pop_cb_label(demo, demo->cmd); // "StagingTexture"

} else {
/* Can't support VK_FORMAT_R8G8B8A8_UNORM !? */
assert(!"No support for R8G8B8A8_UNORM as texture image format");
/* Can't support VK_FORMAT_R8G8B8A8_SRGB !? */
assert(!"No support for R8G8B8A8_SRGB as texture image format");
}

const VkSamplerCreateInfo sampler = {
Expand Down
6 changes: 3 additions & 3 deletions cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,7 @@ void Demo::prepare_texture_image(const char *filename, texture_object &tex_obj,

auto const image_create_info = vk::ImageCreateInfo()
.setImageType(vk::ImageType::e2D)
.setFormat(vk::Format::eR8G8B8A8Unorm)
.setFormat(vk::Format::eR8G8B8A8Srgb)
.setExtent({tex_obj.tex_width, tex_obj.tex_height, 1})
.setMipLevels(1)
.setArrayLayers(1)
Expand Down Expand Up @@ -2641,7 +2641,7 @@ void Demo::prepare_texture_image(const char *filename, texture_object &tex_obj,
}

void Demo::prepare_textures() {
vk::Format const tex_format = vk::Format::eR8G8B8A8Unorm;
vk::Format const tex_format = vk::Format::eR8G8B8A8Srgb;
vk::FormatProperties props;
gpu.getFormatProperties(tex_format, &props);

Expand Down Expand Up @@ -2689,7 +2689,7 @@ void Demo::prepare_textures() {
textures[i].imageLayout, vk::AccessFlagBits::eTransferWrite, vk::PipelineStageFlagBits::eTransfer,
vk::PipelineStageFlagBits::eFragmentShader);
} else {
assert(!"No support for R8G8B8A8_UNORM as texture image format");
assert(!"No support for R8G8B8A8_SRGB as texture image format");
}

auto const samplerInfo = vk::SamplerCreateInfo()
Expand Down
18 changes: 17 additions & 1 deletion cube/cube.frag
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,26 @@ layout (location = 0) out vec4 uFragColor;

const vec3 lightDir= vec3(0.424, 0.566, 0.707);

float linearToSrgb(float linear) {
if (linear <= 0.0031308) {
return linear * 12.92;
} else {
return (1.055 * pow(linear, 1.0/2.4)) - 0.055;
}
}

vec3 linearToSrgb(vec3 linear) {
return vec3(linearToSrgb(linear.r), linearToSrgb(linear.g), linearToSrgb(linear.b));
}

vec4 linearToSrgb(vec4 linear) {
return vec4(linearToSrgb(linear.rgb), linear.a);
}

void main() {
vec3 dX = dFdx(frag_pos);
vec3 dY = dFdy(frag_pos);
vec3 normal = normalize(cross(dX,dY));
float light = max(0.0, dot(lightDir, normal));
uFragColor = light * texture(tex, texcoord.xy);
uFragColor = linearToSrgb(light * texture(tex, texcoord.xy));
}
117 changes: 80 additions & 37 deletions cube/cube.frag.inc
Original file line number Diff line number Diff line change
@@ -1,41 +1,84 @@
// 7.9.2888
0x07230203,0x00010000,0x00080007,0x00000030,0x00000000,0x00020011,0x00000001,0x0006000b,
// 1115.1.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's a lot of versions of glslang

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure when the checked in code was compiled, because Vulkan-Tools used to compile glslang, then it went to just downloading the binary, to the current checked in state.

0x07230203,0x00010000,0x0008000b,0x00000073,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x00000022,0x0000002a,
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000004e,0x00000063,0x0000006b,
0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,
0x415f4c47,0x735f4252,0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000009,0x00005864,0x00050005,
0x0000000b,0x67617266,0x736f705f,0x00000000,0x00030005,0x0000000e,0x00005964,0x00040005,
0x00000011,0x6d726f6e,0x00006c61,0x00040005,0x00000017,0x6867696c,0x00000074,0x00050005,
0x00000022,0x61724675,0x6c6f4367,0x0000726f,0x00030005,0x00000027,0x00786574,0x00050005,
0x0000002a,0x63786574,0x64726f6f,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000001,
0x00040047,0x00000022,0x0000001e,0x00000000,0x00040047,0x00000027,0x00000022,0x00000000,
0x00040047,0x00000027,0x00000021,0x00000001,0x00040047,0x0000002a,0x0000001e,0x00000000,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007,
0x00040020,0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,
0x00040020,0x00000016,0x00000007,0x00000006,0x0004002b,0x00000006,0x00000018,0x00000000,
0x0004002b,0x00000006,0x00000019,0x3ed91687,0x0004002b,0x00000006,0x0000001a,0x3f10e560,
0x0004002b,0x00000006,0x0000001b,0x3f34fdf4,0x0006002c,0x00000007,0x0000001c,0x00000019,
0x0000001a,0x0000001b,0x00040017,0x00000020,0x00000006,0x00000004,0x00040020,0x00000021,
0x00000003,0x00000020,0x0004003b,0x00000021,0x00000022,0x00000003,0x00090019,0x00000024,
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,
0x00000025,0x00000024,0x00040020,0x00000026,0x00000000,0x00000025,0x0004003b,0x00000026,
0x00000027,0x00000000,0x00040020,0x00000029,0x00000001,0x00000020,0x0004003b,0x00000029,
0x0000002a,0x00000001,0x00040017,0x0000002b,0x00000006,0x00000002,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,
0x00000007,0x0004003b,0x00000008,0x0000000e,0x00000007,0x0004003b,0x00000008,0x00000011,
0x00000007,0x0004003b,0x00000016,0x00000017,0x00000007,0x0004003d,0x00000007,0x0000000c,
0x0000000b,0x000400cf,0x00000007,0x0000000d,0x0000000c,0x0003003e,0x00000009,0x0000000d,
0x0004003d,0x00000007,0x0000000f,0x0000000b,0x000400d0,0x00000007,0x00000010,0x0000000f,
0x0003003e,0x0000000e,0x00000010,0x0004003d,0x00000007,0x00000012,0x00000009,0x0004003d,
0x00000007,0x00000013,0x0000000e,0x0007000c,0x00000007,0x00000014,0x00000001,0x00000044,
0x00000012,0x00000013,0x0006000c,0x00000007,0x00000015,0x00000001,0x00000045,0x00000014,
0x0003003e,0x00000011,0x00000015,0x0004003d,0x00000007,0x0000001d,0x00000011,0x00050094,
0x00000006,0x0000001e,0x0000001c,0x0000001d,0x0007000c,0x00000006,0x0000001f,0x00000001,
0x00000028,0x00000018,0x0000001e,0x0003003e,0x00000017,0x0000001f,0x0004003d,0x00000006,
0x00000023,0x00000017,0x0004003d,0x00000025,0x00000028,0x00000027,0x0004003d,0x00000020,
0x0000002c,0x0000002a,0x0007004f,0x0000002b,0x0000002d,0x0000002c,0x0000002c,0x00000000,
0x00000001,0x00050057,0x00000020,0x0000002e,0x00000028,0x0000002d,0x0005008e,0x00000020,
0x0000002f,0x0000002e,0x00000023,0x0003003e,0x00000022,0x0000002f,0x000100fd,0x00010038
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00070005,0x0000000a,0x656e696c,0x6f547261,
0x62677253,0x3b316628,0x00000000,0x00040005,0x00000009,0x656e696c,0x00007261,0x00070005,
0x00000010,0x656e696c,0x6f547261,0x62677253,0x33667628,0x0000003b,0x00040005,0x0000000f,
0x656e696c,0x00007261,0x00070005,0x00000016,0x656e696c,0x6f547261,0x62677253,0x34667628,
0x0000003b,0x00040005,0x00000015,0x656e696c,0x00007261,0x00040005,0x0000002c,0x61726170,
0x0000006d,0x00040005,0x00000032,0x61726170,0x0000006d,0x00040005,0x00000037,0x61726170,
0x0000006d,0x00040005,0x0000003f,0x61726170,0x0000006d,0x00030005,0x0000004c,0x00005864,
0x00050005,0x0000004e,0x67617266,0x736f705f,0x00000000,0x00030005,0x00000051,0x00005964,
0x00040005,0x00000054,0x6d726f6e,0x00006c61,0x00040005,0x00000059,0x6867696c,0x00000074,
0x00050005,0x00000063,0x61724675,0x6c6f4367,0x0000726f,0x00030005,0x00000068,0x00786574,
0x00050005,0x0000006b,0x63786574,0x64726f6f,0x00000000,0x00040005,0x00000071,0x61726170,
0x0000006d,0x00040047,0x0000004e,0x0000001e,0x00000001,0x00040047,0x00000063,0x0000001e,
0x00000000,0x00040047,0x00000068,0x00000021,0x00000001,0x00040047,0x00000068,0x00000022,
0x00000000,0x00040047,0x0000006b,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,
0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007,0x00000007,
0x00000006,0x00040021,0x00000008,0x00000006,0x00000007,0x00040017,0x0000000c,0x00000006,
0x00000003,0x00040020,0x0000000d,0x00000007,0x0000000c,0x00040021,0x0000000e,0x0000000c,
0x0000000d,0x00040017,0x00000012,0x00000006,0x00000004,0x00040020,0x00000013,0x00000007,
0x00000012,0x00040021,0x00000014,0x00000012,0x00000013,0x0004002b,0x00000006,0x00000019,
0x3b4d2e1c,0x00020014,0x0000001a,0x0004002b,0x00000006,0x0000001f,0x414eb852,0x0004002b,
0x00000006,0x00000023,0x3f870a3d,0x0004002b,0x00000006,0x00000025,0x3ed55555,0x0004002b,
0x00000006,0x00000028,0x3d6147ae,0x00040015,0x0000002d,0x00000020,0x00000000,0x0004002b,
0x0000002d,0x0000002e,0x00000000,0x0004002b,0x0000002d,0x00000033,0x00000001,0x0004002b,
0x0000002d,0x00000038,0x00000002,0x0004002b,0x0000002d,0x00000043,0x00000003,0x00040020,
0x0000004d,0x00000001,0x0000000c,0x0004003b,0x0000004d,0x0000004e,0x00000001,0x0004002b,
0x00000006,0x0000005a,0x00000000,0x0004002b,0x00000006,0x0000005b,0x3ed91687,0x0004002b,
0x00000006,0x0000005c,0x3f10e560,0x0004002b,0x00000006,0x0000005d,0x3f34fdf4,0x0006002c,
0x0000000c,0x0000005e,0x0000005b,0x0000005c,0x0000005d,0x00040020,0x00000062,0x00000003,
0x00000012,0x0004003b,0x00000062,0x00000063,0x00000003,0x00090019,0x00000065,0x00000006,
0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000066,
0x00000065,0x00040020,0x00000067,0x00000000,0x00000066,0x0004003b,0x00000067,0x00000068,
0x00000000,0x00040020,0x0000006a,0x00000001,0x00000012,0x0004003b,0x0000006a,0x0000006b,
0x00000001,0x00040017,0x0000006c,0x00000006,0x00000002,0x00050036,0x00000002,0x00000004,
0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d,0x0000004c,0x00000007,
0x0004003b,0x0000000d,0x00000051,0x00000007,0x0004003b,0x0000000d,0x00000054,0x00000007,
0x0004003b,0x00000007,0x00000059,0x00000007,0x0004003b,0x00000013,0x00000071,0x00000007,
0x0004003d,0x0000000c,0x0000004f,0x0000004e,0x000400cf,0x0000000c,0x00000050,0x0000004f,
0x0003003e,0x0000004c,0x00000050,0x0004003d,0x0000000c,0x00000052,0x0000004e,0x000400d0,
0x0000000c,0x00000053,0x00000052,0x0003003e,0x00000051,0x00000053,0x0004003d,0x0000000c,
0x00000055,0x0000004c,0x0004003d,0x0000000c,0x00000056,0x00000051,0x0007000c,0x0000000c,
0x00000057,0x00000001,0x00000044,0x00000055,0x00000056,0x0006000c,0x0000000c,0x00000058,
0x00000001,0x00000045,0x00000057,0x0003003e,0x00000054,0x00000058,0x0004003d,0x0000000c,
0x0000005f,0x00000054,0x00050094,0x00000006,0x00000060,0x0000005e,0x0000005f,0x0007000c,
0x00000006,0x00000061,0x00000001,0x00000028,0x0000005a,0x00000060,0x0003003e,0x00000059,
0x00000061,0x0004003d,0x00000006,0x00000064,0x00000059,0x0004003d,0x00000066,0x00000069,
0x00000068,0x0004003d,0x00000012,0x0000006d,0x0000006b,0x0007004f,0x0000006c,0x0000006e,
0x0000006d,0x0000006d,0x00000000,0x00000001,0x00050057,0x00000012,0x0000006f,0x00000069,
0x0000006e,0x0005008e,0x00000012,0x00000070,0x0000006f,0x00000064,0x0003003e,0x00000071,
0x00000070,0x00050039,0x00000012,0x00000072,0x00000016,0x00000071,0x0003003e,0x00000063,
0x00000072,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,
0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003d,0x00000006,0x00000018,
0x00000009,0x000500bc,0x0000001a,0x0000001b,0x00000018,0x00000019,0x000300f7,0x0000001d,
0x00000000,0x000400fa,0x0000001b,0x0000001c,0x00000022,0x000200f8,0x0000001c,0x0004003d,
0x00000006,0x0000001e,0x00000009,0x00050085,0x00000006,0x00000020,0x0000001e,0x0000001f,
0x000200fe,0x00000020,0x000200f8,0x00000022,0x0004003d,0x00000006,0x00000024,0x00000009,
0x0007000c,0x00000006,0x00000026,0x00000001,0x0000001a,0x00000024,0x00000025,0x00050085,
0x00000006,0x00000027,0x00000023,0x00000026,0x00050083,0x00000006,0x00000029,0x00000027,
0x00000028,0x000200fe,0x00000029,0x000200f8,0x0000001d,0x000100ff,0x00010038,0x00050036,
0x0000000c,0x00000010,0x00000000,0x0000000e,0x00030037,0x0000000d,0x0000000f,0x000200f8,
0x00000011,0x0004003b,0x00000007,0x0000002c,0x00000007,0x0004003b,0x00000007,0x00000032,
0x00000007,0x0004003b,0x00000007,0x00000037,0x00000007,0x00050041,0x00000007,0x0000002f,
0x0000000f,0x0000002e,0x0004003d,0x00000006,0x00000030,0x0000002f,0x0003003e,0x0000002c,
0x00000030,0x00050039,0x00000006,0x00000031,0x0000000a,0x0000002c,0x00050041,0x00000007,
0x00000034,0x0000000f,0x00000033,0x0004003d,0x00000006,0x00000035,0x00000034,0x0003003e,
0x00000032,0x00000035,0x00050039,0x00000006,0x00000036,0x0000000a,0x00000032,0x00050041,
0x00000007,0x00000039,0x0000000f,0x00000038,0x0004003d,0x00000006,0x0000003a,0x00000039,
0x0003003e,0x00000037,0x0000003a,0x00050039,0x00000006,0x0000003b,0x0000000a,0x00000037,
0x00060050,0x0000000c,0x0000003c,0x00000031,0x00000036,0x0000003b,0x000200fe,0x0000003c,
0x00010038,0x00050036,0x00000012,0x00000016,0x00000000,0x00000014,0x00030037,0x00000013,
0x00000015,0x000200f8,0x00000017,0x0004003b,0x0000000d,0x0000003f,0x00000007,0x0004003d,
0x00000012,0x00000040,0x00000015,0x0008004f,0x0000000c,0x00000041,0x00000040,0x00000040,
0x00000000,0x00000001,0x00000002,0x0003003e,0x0000003f,0x00000041,0x00050039,0x0000000c,
0x00000042,0x00000010,0x0000003f,0x00050041,0x00000007,0x00000044,0x00000015,0x00000043,
0x0004003d,0x00000006,0x00000045,0x00000044,0x00050051,0x00000006,0x00000046,0x00000042,
0x00000000,0x00050051,0x00000006,0x00000047,0x00000042,0x00000001,0x00050051,0x00000006,
0x00000048,0x00000042,0x00000002,0x00070050,0x00000012,0x00000049,0x00000046,0x00000047,
0x00000048,0x00000045,0x000200fe,0x00000049,0x00010038
20 changes: 10 additions & 10 deletions cube/cube.vert.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 7.9.2888
0x07230203,0x00010000,0x00080007,0x0000002f,0x00000000,0x00020011,0x00000001,0x0006000b,
// 1115.1.0
0x07230203,0x00010000,0x0008000b,0x0000002f,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000015,0x0000001e,
0x0000002b,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252,0x72617065,
Expand All @@ -15,14 +15,14 @@
0x00000002,0x435f6c67,0x4470696c,0x61747369,0x0065636e,0x00030005,0x0000001e,0x00000000,
0x00050005,0x0000002b,0x67617266,0x736f705f,0x00000000,0x00040047,0x00000009,0x0000001e,
0x00000000,0x00040047,0x0000000d,0x00000006,0x00000010,0x00040047,0x0000000e,0x00000006,
0x00000010,0x00040048,0x0000000f,0x00000000,0x00000005,0x00050048,0x0000000f,0x00000000,
0x00000023,0x00000000,0x00050048,0x0000000f,0x00000000,0x00000007,0x00000010,0x00050048,
0x0000000f,0x00000001,0x00000023,0x00000040,0x00050048,0x0000000f,0x00000002,0x00000023,
0x00000280,0x00030047,0x0000000f,0x00000002,0x00040047,0x00000011,0x00000022,0x00000000,
0x00040047,0x00000011,0x00000021,0x00000000,0x00040047,0x00000015,0x0000000b,0x0000002a,
0x00050048,0x0000001c,0x00000000,0x0000000b,0x00000000,0x00050048,0x0000001c,0x00000001,
0x0000000b,0x00000001,0x00050048,0x0000001c,0x00000002,0x0000000b,0x00000003,0x00030047,
0x0000001c,0x00000002,0x00040047,0x0000002b,0x0000001e,0x00000001,0x00020013,0x00000002,
0x00000010,0x00030047,0x0000000f,0x00000002,0x00040048,0x0000000f,0x00000000,0x00000005,
0x00050048,0x0000000f,0x00000000,0x00000007,0x00000010,0x00050048,0x0000000f,0x00000000,
0x00000023,0x00000000,0x00050048,0x0000000f,0x00000001,0x00000023,0x00000040,0x00050048,
0x0000000f,0x00000002,0x00000023,0x00000280,0x00040047,0x00000011,0x00000021,0x00000000,
0x00040047,0x00000011,0x00000022,0x00000000,0x00040047,0x00000015,0x0000000b,0x0000002a,
0x00030047,0x0000001c,0x00000002,0x00050048,0x0000001c,0x00000000,0x0000000b,0x00000000,
0x00050048,0x0000001c,0x00000001,0x0000000b,0x00000001,0x00050048,0x0000001c,0x00000002,
0x0000000b,0x00000003,0x00040047,0x0000002b,0x0000001e,0x00000001,0x00020013,0x00000002,
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,
0x00000009,0x00000003,0x00040018,0x0000000a,0x00000007,0x00000004,0x00040015,0x0000000b,
Expand Down
Loading