Lmao, I was storing normal maps in SRGB texture
This commit is contained in:
parent
58488434f4
commit
61e2c71093
@ -4,6 +4,7 @@
|
||||
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
|
||||
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
|
||||
#include "../../../gen/l1/VecAndSpan_Span_int_primitives.h"
|
||||
#include "../../l1/core/VecU8_as_str.h"
|
||||
|
||||
U8 U8_to_lowercase(U8 ch) {
|
||||
if ('A' <= ch && ch <= 'Z')
|
||||
@ -44,4 +45,9 @@ bool is_string_in_string_vec(SpanU8 a, const VecVecU8* B) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void VecU8_add_vertical_separator(VecU8* self) {
|
||||
if (self->len)
|
||||
VecU8_append_span(self, cstr(" | "));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -192,6 +192,83 @@ VecVecU8 margaret_get_extensions_of_physical_device(VkPhysicalDevice physical_de
|
||||
return res;
|
||||
}
|
||||
|
||||
NODISCARD VecU8 margaret_stringify_memory_heap_flags(VkMemoryHeapFlags flags) {
|
||||
VecU8 result = VecU8_new();
|
||||
/* enum VkMemoryHeapFlagBits */
|
||||
if (flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) {
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_HEAP_DEVICE_LOCAL_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_HEAP_MULTI_INSTANCE_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_HEAP_MULTI_INSTANCE_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_HEAP_TILE_MEMORY_BIT_QCOM) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_HEAP_TILE_MEMORY_BIT_QCOM"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NODISCARD VecU8 margaret_stringify_memory_property_flags(VkMemoryPropertyFlags flags) {
|
||||
VecU8 result = VecU8_new();
|
||||
/* enum VkMemoryPropertyFlagBits */
|
||||
if (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_HOST_COHERENT_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_HOST_CACHED_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_PROTECTED_BIT) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_PROTECTED_BIT"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD"));
|
||||
}
|
||||
if (flags & VK_MEMORY_PROPERTY_RDMA_CAPABLE_BIT_NV) {
|
||||
VecU8_add_vertical_separator(&result);
|
||||
VecU8_append_span(&result, cstr("VK_MEMORY_PROPERTY_RDMA_CAPABLE_BIT_NV"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NODISCARD VecU8 margaret_stringify_device_memory_properties(VkPhysicalDevice physical_device) {
|
||||
VkPhysicalDeviceMemoryProperties properties;
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device, &properties);
|
||||
VecU8 result = VecU8_new();
|
||||
for (size_t h = 0; h < properties.memoryHeapCount; h++) {
|
||||
VecU8_append_vec(&result, VecU8_format("-+ Heap %ld of %lu bytes [ ", h, properties.memoryHeaps[h].size));
|
||||
VecU8_append_vec(&result, margaret_stringify_memory_heap_flags(properties.memoryHeaps[h].flags));
|
||||
VecU8_append_span(&result, cstr(" ], mem types below\n"));
|
||||
for (size_t t = 0; t < properties.memoryTypeCount; t++) {
|
||||
if (properties.memoryTypes->heapIndex == h) {
|
||||
VecU8_append_vec(&result, VecU8_format("----> Mem type %lu [ ", t));
|
||||
VecU8_append_vec(&result, margaret_stringify_memory_property_flags(properties.memoryTypes[t].propertyFlags));
|
||||
VecU8_append_span(&result, cstr(" ]\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VkDevice margaret_create_logical_device(VkPhysicalDevice physical_device, MargaretChosenQueueFamilies queue_fam) {
|
||||
VkPhysicalDeviceFeatures physical_features;
|
||||
vkGetPhysicalDeviceFeatures(physical_device, &physical_features);
|
||||
@ -433,6 +510,12 @@ MargaretScoredPhysicalDevice margaret_score_physical_device(
|
||||
vkGetPhysicalDeviceProperties(dev, &properties);
|
||||
if (string_contains_string_ignorecase(SpanU8_from_cstr(properties.deviceName), forbidden_word))
|
||||
return (MargaretScoredPhysicalDevice){ dev, -1, cstr("Bugged gpu") };
|
||||
{ /* Here I print a little bit of memory properties */
|
||||
printf("MEMORY OF %s\n", properties.deviceName); // todo: score device based on memory
|
||||
VecU8 txt = margaret_stringify_device_memory_properties(dev);
|
||||
SpanU8_print(VecU8_to_span(&txt));
|
||||
VecU8_drop(txt);
|
||||
}
|
||||
VkPhysicalDeviceSynchronization2Features synchronization2_features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES,
|
||||
};
|
||||
@ -854,7 +937,7 @@ VkDeviceMemory margaret_initialize_buffers_and_images(
|
||||
VkMemoryRequirements memory_requirements;
|
||||
vkGetBufferMemoryRequirements(device, buf_hand->buffer, &memory_requirements);
|
||||
|
||||
memory_types_allowed |= memory_requirements.memoryTypeBits;
|
||||
memory_types_allowed &= memory_requirements.memoryTypeBits;
|
||||
offset = margaret_align_start_of_buffer(offset, memory_requirements.alignment);
|
||||
buf_hand->offset = offset;
|
||||
offset = offset + memory_requirements.size;
|
||||
@ -884,7 +967,7 @@ VkDeviceMemory margaret_initialize_buffers_and_images(
|
||||
VkMemoryRequirements memory_requirements;
|
||||
vkGetImageMemoryRequirements(device, img_hand->image, &memory_requirements);
|
||||
|
||||
memory_types_allowed |= memory_requirements.memoryTypeBits;
|
||||
memory_types_allowed &= memory_requirements.memoryTypeBits;
|
||||
offset = margaret_align_start_of_buffer(offset, memory_requirements.alignment);
|
||||
img_hand->offset = offset;
|
||||
offset = offset + memory_requirements.size;
|
||||
|
||||
@ -1839,7 +1839,7 @@ int main() {
|
||||
MAX_WIN_WIDTH, MAX_WIN_HEIGHT, zbuffer_format.some);
|
||||
state.vk_ctx.device_cyl_1_diffuse_texture = margaret_prep_image_mem_info_of_gpu_texture_srgba(
|
||||
state.vk_ctx.cyl_1_diffuse_tex.width, TextureDataR8G8B8A8_get_height(&state.vk_ctx.cyl_1_diffuse_tex));
|
||||
state.vk_ctx.device_cyl_1_normal_texture = margaret_prep_image_mem_info_of_gpu_texture_srgba(
|
||||
state.vk_ctx.device_cyl_1_normal_texture = margaret_prep_image_mem_info_of_gpu_texture_unorm_32(
|
||||
state.vk_ctx.cyl_1_normal_tex.width, TextureDataR8G8B8A8_get_height(&state.vk_ctx.cyl_1_normal_tex));
|
||||
|
||||
PtrMargaretImageInMemoryInfo device_mem_images_SPAN[] = {
|
||||
|
||||
@ -33,7 +33,7 @@ layout(std140, binding = 0) uniform Pipeline0UBO {
|
||||
};
|
||||
|
||||
float get_intensity(float dist){
|
||||
return 1 / pow(dist + 1, 2);
|
||||
return 1 / (dist * dist * 1.8 + dist * 0.7 + 1);
|
||||
}
|
||||
|
||||
void main(){
|
||||
@ -48,7 +48,9 @@ void main(){
|
||||
vec3 U = to_light / dist;
|
||||
diffuse_illumination += get_intensity(dist) * max(0.02, dot(U, norm)) * lamp.color;
|
||||
vec3 A = reflect(-U, norm);
|
||||
vec3 B = normalize(-fsin_pos+camera_pos);
|
||||
vec3 to_cam = -fsin_pos+camera_pos;
|
||||
float dist_to_cam = length(to_cam);
|
||||
vec3 B = to_cam / dist_to_cam;
|
||||
specular_illumination += get_intensity(dist) * pow(max(0, dot(A, B)), 32) * lamp.color;
|
||||
}
|
||||
for (int i = 0; i < spotlight_count; i++) {
|
||||
@ -58,6 +60,7 @@ void main(){
|
||||
// todo: add specular map texture
|
||||
vec3 color = natural_color * diffuse_illumination + 0.5 * specular_illumination;
|
||||
fin_color = vec4(color, 1);
|
||||
// fin_color = vec4(length(norm) / 2, 0, 0, 1);
|
||||
// fin_color = vec4(fsin_tex, 0, 1);
|
||||
// fin_color = vec4(compressed_normal, 1);
|
||||
// fin_color = vec4(specular_illumination, 1);
|
||||
// fin_color = vec4(length(norm) > 1 ? length(norm) - 1 : 0, length(norm) < 1 ? length(norm) - 1 : 0, 0, 1);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ layout(std140, binding = 0) uniform Pipeline0UBO {
|
||||
};
|
||||
|
||||
float get_intensity(float dist){
|
||||
return 1 / pow(dist + 1, 2);
|
||||
return 1 / (dist * dist * 1.8 + dist * 0.7 + 1);
|
||||
}
|
||||
|
||||
void main(){
|
||||
|
||||
@ -16,4 +16,5 @@ void main() {
|
||||
vec2 tex_offset = 1.0 / textureSize(prev, 0);
|
||||
vec4 hdr_color = texture(prev, gl_FragCoord.xy * tex_offset);
|
||||
fin_color = vec4(vec3(1) - exp(-hdr_factor * hdr_color.xyz), 1);
|
||||
// fin_color = hdr_color;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user