Skip to content

Instantly share code, notes, and snippets.

@nyorain
nyorain / pageVector.hpp
Created March 17, 2021 20:16
PageVector
// VIL: Vulkan Live Introspection & Debugging Layer.
// Copyright (C) 2020-2021 Jan Kelling
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <cstdlib> // size_t
#include <cassert> // assert
#include <type_traits> // std::aligned_storage_t
#include <utility> // std::forward/std::move
00:00:01.131 [render/vulkan/vulkan.c:510] vulkan: VK_EXT_queue_family_foreign not supported
00:00:01.131 [render/vulkan/vulkan.c:523] YCbCr device feature: 1
00:00:01.136 [render/vulkan/pixel_format.c:327] vulkan: Format AR24 (0x34325241), mod 0x0 supported for render buffer importing
00:00:01.136 [render/vulkan/pixel_format.c:366] vulkan: Format AR24 (0x34325241), mod 0x0 supported for texture importing
00:00:01.136 [render/vulkan/pixel_format.c:327] vulkan: Format AR24 (0x34325241), mod 0x100000000000001 supported for render buffer importing
00:00:01.136 [render/vulkan/pixel_format.c:366] vulkan: Format AR24 (0x34325241), mod 0x100000000000001 supported for texture importing
00:00:01.136 [render/vulkan/pixel_format.c:327] vulkan: Format AR24 (0x34325241), mod 0x100000000000002 supported for render buffer importing
00:00:01.136 [render/vulkan/pixel_format.c:366] vulkan: Format AR24 (0x34325241), mod 0x100000000000002 supported for texture importing
00:00:01.136 [render/vulkan/pixel_format.c:397] vulkan: Form
@nyorain
nyorain / example.cpp
Created March 31, 2020 22:01
Simple parser
#include "parser.hpp"
#include <vector>
#include <memory>
#include <string>
#include <variant>
#include <iostream>
template<typename ...Ts>
struct Visitor : Ts... {
Visitor(const Ts&... args) : Ts(args)... {}
@nyorain
nyorain / luminance.diff
Created November 2, 2019 20:19
Alternative luminance mipmapping using SIMD
diff --git a/src/deferred/luminance.cpp b/src/deferred/luminance.cpp
index 92351e1..7e2e922 100644
--- a/src/deferred/luminance.cpp
+++ b/src/deferred/luminance.cpp
@@ -256,7 +256,7 @@ void LuminancePass::initBuffers(InitBufferData& data, vk::ImageView light,
dsu.apply();
// mip levels
- const auto mf = (mipGroupDimSize * 4); // minification factor
+ const auto mf = (mipGroupDimSize * 8); // minification factor
@nyorain
nyorain / vkgl.cpp
Last active March 6, 2021 03:55
Vulkan GL format map
constexpr struct FormatEntry {
GLInternalFormat glFormat;
u32 glPixelFormat;
u32 glPixelType;
vk::Format vkFormat;
} formatMap[] = {
// 8bit
{GL_R8, GL_RED, GL_UNSIGNED_BYTE, vk::Format::r8Unorm},
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE, vk::Format::r8g8Unorm},
{GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, vk::Format::r8g8b8Unorm},
==8317== Memcheck, a memory error detector
==8317== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==8317== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==8317== Command: ./rootston/rootston
==8317==
2018-10-12 20:29:20 - [rootston/config.c:505] No config file found. Using sensible defaults.
2018-10-12 20:29:23 - [render/egl.c:145] Using EGL 1.5
2018-10-12 20:29:23 - [render/egl.c:146] Supported EGL extensions: EGL_ANDROID_native_fence_sync EGL_CHROMIUM_sync_control EGL_EXT_buffer_age EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pi
PID: 22994 (rootston)
UID: 1000 (nyorain)
GID: 1000 (nyorain)
Signal: 11 (SEGV)
Timestamp: Fri 2018-10-12 20:10:34 CEST (47s ago)
Command Line: ./rootston/rootston
Executable: /mnt/data/code/wlr/build/rootston/rootston
Control Group: /user.slice/user-1000.slice/session-1.scope
Unit: session-1.scope
Slice: user-1000.slice
[3934530.276] -> [email protected]_registry(new id wl_registry@2)
[3934530.410] -> [email protected](new id wl_callback@3)
[3934530.567] [email protected]_id(3)
[3934530.639] [email protected](1, "wl_data_device_manager", 3)
[3934530.828] -> [email protected](1, "wl_data_device_manager", 3, new id [unknown]@4)
[3934531.079] [email protected](2, "wl_shm", 1)
[3934531.253] -> [email protected](2, "wl_shm", 1, new id [unknown]@5)
[3934531.538] -> [email protected]_pool(new id wl_shm_pool@6, fd 10, 2304)
[3934532.011] -> [email protected](6912)
[3934532.192] -> [email protected](16128)
IndentWidth: 4
PointerAlignment: Left
Language: Cpp
UseTab: ForIndentation
TabWidth: 4
ColumnLimit: 80
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
// GraphicsPipelineInfo
GraphicsPipelineInfo::GraphicsPipelineInfo(vk::RenderPass renderPass,
vk::PipelineLayout layout, vk::SampleCountBits samples,
vpp::ShaderProgram&& prog)
{
static const auto dynStates = {
vk::DynamicState::viewport,
vk::DynamicState::scissor};
blendAttachment.blendEnable = true;