Cleanup: make format and fix warning

This commit is contained in:
Jacques Lucke 2022-03-22 13:44:15 +01:00
parent 19c793af35
commit 2ebcb7fab3
8 changed files with 48 additions and 30 deletions

View File

@ -47,11 +47,12 @@ void GPU_context_main_lock(void);
void GPU_context_main_unlock(void);
/* GPU Begin/end work blocks */
void GPU_render_begin();
void GPU_render_end();
void GPU_render_begin(void);
void GPU_render_end(void);
/* For operations which need to run exactly once per frame -- even if there are no render updates. */
void GPU_render_step();
/* For operations which need to run exactly once per frame -- even if there are no render updates.
*/
void GPU_render_step(void);
#ifdef __cplusplus
}

View File

@ -58,10 +58,13 @@ extern "C" {
#endif
/* GPU Types */
/* TODO: Verify all use-cases of GPU_type_matches to determine which graphics API it should apply to, and replace
* with `GPU_type_matches_ex` where appropriate. */
/* TODO: Verify all use-cases of GPU_type_matches to determine which graphics API it should apply
* to, and replace with `GPU_type_matches_ex` where appropriate. */
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver);
bool GPU_type_matches_ex(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver, eGPUBackendType backend);
bool GPU_type_matches_ex(eGPUDeviceType device,
eGPUOSType os,
eGPUDriverType driver,
eGPUBackendType backend);
eGPUSupportLevel GPU_platform_support_level(void);
const char *GPU_platform_vendor(void);

View File

@ -14,7 +14,7 @@
/* TODO: Create cmake option. */
#if WITH_OPENGL
#define WITH_OPENGL_BACKEND 1
# define WITH_OPENGL_BACKEND 1
#endif
#include "BLI_assert.h"
@ -152,18 +152,21 @@ void GPU_context_main_unlock()
* Used for global autoreleasepool flushing in Metal
* \{ */
void GPU_render_begin() {
GPUBackend* backend = GPUBackend::get();
void GPU_render_begin()
{
GPUBackend *backend = GPUBackend::get();
BLI_assert(backend);
backend->render_begin();
}
void GPU_render_end() {
GPUBackend* backend = GPUBackend::get();
void GPU_render_end()
{
GPUBackend *backend = GPUBackend::get();
BLI_assert(backend);
backend->render_end();
}
void GPU_render_step() {
GPUBackend* backend = GPUBackend::get();
void GPU_render_step()
{
GPUBackend *backend = GPUBackend::get();
BLI_assert(backend);
backend->render_step();
}
@ -229,7 +232,7 @@ void GPU_backend_exit()
eGPUBackendType GPU_backend_get_type()
{
#ifdef WITH_OPENGL_BACKEND
if (g_backend && dynamic_cast<GLBackend *>(g_backend) != nullptr) {
return GPU_BACKEND_OPENGL;

View File

@ -148,10 +148,14 @@ bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType drive
return GPU_type_matches_ex(device, os, driver, GPU_BACKEND_ANY);
}
bool GPU_type_matches_ex(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver, eGPUBackendType backend)
bool GPU_type_matches_ex(eGPUDeviceType device,
eGPUOSType os,
eGPUDriverType driver,
eGPUBackendType backend)
{
BLI_assert(GPG.initialized);
return (GPG.device & device) && (GPG.os & os) && (GPG.driver & driver) && (GPG.backend & backend);
return (GPG.device & device) && (GPG.os & os) && (GPG.driver & driver) &&
(GPG.backend & backend);
}
/** \} */

View File

@ -318,7 +318,7 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
/* Initialise Capabilities. */
MTLBackend::capabilities.supports_argument_buffers_tier2 = ([device argumentBuffersSupport] ==
MTLArgumentBuffersTier2);
MTLArgumentBuffersTier2);
MTLBackend::capabilities.supports_family_mac1 = [device supportsFamily:MTLGPUFamilyMac1];
MTLBackend::capabilities.supports_family_mac2 = [device supportsFamily:MTLGPUFamilyMac2];
MTLBackend::capabilities.supports_family_mac_catalyst1 = [device
@ -347,7 +347,7 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
/* Conservative uniform data limit is 4KB per-stage -- This is the limit of setBytes.
* MTLBuffer path is also supported but not as efficient. */
GCaps.max_uniforms_vert = 1024;
GCaps.max_uniforms_vert = 1024;
GCaps.max_uniforms_frag = 1024;
GCaps.max_batch_indices = 1 << 31;
@ -364,7 +364,7 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
GCaps.shader_storage_buffer_objects_support =
false; /* TODO(Metal): implement Storage Buffer support.*/
/* Maximum buffer bindings: 31. Consider required slot for uniforms/UBOs/Vertex attributes.
/* Maximum buffer bindings: 31. Consider required slot for uniforms/UBOs/Vertex attributes.
* Can use argument buffers if a higher limit is required. */
GCaps.max_shader_storage_buffer_bindings = 24;
@ -373,11 +373,13 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
GCaps.max_work_group_count[1] = 65535;
GCaps.max_work_group_count[2] = 65535;
/* In Metal, total_thread_count is 512 or 1024, such that
/* In Metal, total_thread_count is 512 or 1024, such that
* threadgroup `width*height*depth <= total_thread_count` */
unsigned int max_threads_per_threadgroup_per_dim =
([device supportsFamily:MTLGPUFamilyApple4] ||
MTLBackend::capabilities.supports_family_mac1) ? 1024 : 512;
unsigned int max_threads_per_threadgroup_per_dim =
([device supportsFamily:MTLGPUFamilyApple4] ||
MTLBackend::capabilities.supports_family_mac1) ?
1024 :
512;
GCaps.max_work_group_size[0] = max_threads_per_threadgroup_per_dim;
GCaps.max_work_group_size[1] = max_threads_per_threadgroup_per_dim;
GCaps.max_work_group_size[2] = max_threads_per_threadgroup_per_dim;
@ -394,7 +396,8 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
GCaps.broken_amd_driver = false;
/* Metal related workarounds. */
/* Minimum per-vertex stride is 4 bytes in Metal. A bound vertex buffer must contribute atleast 4 bytes per vertex. */
/* Minimum per-vertex stride is 4 bytes in Metal. A bound vertex buffer must contribute atleast 4
* bytes per vertex. */
GCaps.minimum_per_vertex_stride = 4;
}

View File

@ -34,7 +34,7 @@ void main()
{
fragColor = texture(image_texture, texCoord_interp.xy);
vec4 overlay_col = texture(overlays_texture, texCoord_interp.xy);
if (overlay) {
fragColor = clamp(fragColor, 0.0, 1.0);
fragColor *= 1.0 - overlay_col.a;

View File

@ -28,8 +28,9 @@ void main()
vec2 interp_offset = float(interp_size) / abs(pos.zw - pos.xy);
texCoord_interp = mix(-interp_offset, 1.0 + interp_offset, quad);
vec2 final_pos = mix(
vec2(ivec2(pos.xy) + ivec2(-interp_size, interp_size)), vec2(ivec2(pos.zw) + ivec2(interp_size, -interp_size)), quad);
vec2 final_pos = mix(vec2(ivec2(pos.xy) + ivec2(-interp_size, interp_size)),
vec2(ivec2(pos.zw) + ivec2(interp_size, -interp_size)),
quad);
gl_Position = ModelViewProjectionMatrix * vec4(final_pos, 0.0, 1.0);
}

View File

@ -1,5 +1,8 @@
void node_light_falloff(
float strength, float tsmooth, out float quadratic, out float linear, out float falloff_constant)
void node_light_falloff(float strength,
float tsmooth,
out float quadratic,
out float linear,
out float falloff_constant)
{
quadratic = strength;
linear = strength;