The goal is to reduce the startup time cost of all of these parsing and string replacement. All comments are now stripped at compile time. This comment check added noticeable slowdown at startup in debug builds and during preprocessing. Put all metadatas between start and end token. Use very simple parsing using `StringRef` and hash all identifiers. Move all the complexity to the preprocessor that massagess the metadata into a well expected input to the runtime parser. All identifiers are compile time hashed so that no string comparison is made at runtime. Speed up the source loading: - from 10ms to 1.6ms (6.25x speedup) in release - from 194ms to 6ms (32.3x speedup) in debug Follow up #129009 Pull Request: https://projects.blender.org/blender/blender/pulls/128927
30 lines
619 B
GLSL
30 lines
619 B
GLSL
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
uint print_data(uint offset, uint data)
|
|
{
|
|
if (offset < GPU_SHADER_PRINTF_MAX_CAPACITY) {
|
|
gpu_print_buf[offset] = data;
|
|
}
|
|
return offset + 1u;
|
|
}
|
|
|
|
uint print_data(uint offset, int data)
|
|
{
|
|
return print_data(offset, uint(data));
|
|
}
|
|
|
|
uint print_data(uint offset, float data)
|
|
{
|
|
return print_data(offset, floatBitsToUint(data));
|
|
}
|
|
|
|
uint print_header(const uint data_len, uint format_hash)
|
|
{
|
|
uint offset = atomicAdd(gpu_print_buf[0], 1u + data_len) + 1u;
|
|
return print_data(offset, format_hash);
|
|
}
|