Cycles: Markup to disable specialisation of kernel data fields (Metal)
This patch adds markup to specify that certain kernel data constants should not be specialised. Currently it is used for `tabulated_sobol_sequence_size` and `sobol_index_mask` which change frequently based on the aa sample count, trash the shader cache, and have little bearing on performance. Reviewed By: brecht Differential Revision: https://developer.blender.org/D16968
This commit is contained in:
parent
08b3426df9
commit
e270a198a5
|
@ -327,10 +327,19 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat
|
|||
# define KERNEL_STRUCT_BEGIN(name, parent) \
|
||||
string_replace_same_length(source, "kernel_data." #parent ".", "kernel_data_" #parent "_");
|
||||
|
||||
bool next_member_is_specialized = true;
|
||||
|
||||
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
|
||||
|
||||
/* Add constants to md5 so that 'get_best_pipeline' is able to return a suitable match. */
|
||||
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
|
||||
baked_constants += string(#parent "." #name "=") + \
|
||||
to_string(_type(launch_params.data.parent.name)) + "\n";
|
||||
if (next_member_is_specialized) { \
|
||||
baked_constants += string(#parent "." #name "=") + \
|
||||
to_string(_type(launch_params.data.parent.name)) + "\n"; \
|
||||
} else { \
|
||||
string_replace(source, "kernel_data_" #parent "_" #name, "kernel_data." #parent ".__unused_" #name); \
|
||||
next_member_is_specialized = true; \
|
||||
}
|
||||
|
||||
# include "kernel/data_template.h"
|
||||
|
||||
|
|
|
@ -460,13 +460,17 @@ static MTLFunctionConstantValues *GetConstantValues(KernelData const *data = nul
|
|||
if (!data) {
|
||||
data = &zero_data;
|
||||
}
|
||||
int zero_int = 0;
|
||||
[constant_values setConstantValue:&zero_int type:MTLDataType_int atIndex:Kernel_DummyConstant];
|
||||
[constant_values setConstantValue:&zero_data type:MTLDataType_int atIndex:Kernel_DummyConstant];
|
||||
|
||||
bool next_member_is_specialized = true;
|
||||
|
||||
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
|
||||
|
||||
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
|
||||
[constant_values setConstantValue:&data->parent.name \
|
||||
[constant_values setConstantValue:next_member_is_specialized ? (void*)&data->parent.name : (void*)&zero_data \
|
||||
type:MTLDataType_##_type \
|
||||
atIndex:KernelData_##parent##_##name];
|
||||
atIndex:KernelData_##parent##_##name]; \
|
||||
next_member_is_specialized = true;
|
||||
|
||||
# include "kernel/data_template.h"
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#ifndef KERNEL_STRUCT_MEMBER
|
||||
# define KERNEL_STRUCT_MEMBER(parent, type, name)
|
||||
#endif
|
||||
#ifndef KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE
|
||||
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE
|
||||
#endif
|
||||
|
||||
|
||||
/* Background. */
|
||||
|
||||
|
@ -179,8 +183,8 @@ KERNEL_STRUCT_MEMBER(integrator, float, sample_clamp_indirect)
|
|||
KERNEL_STRUCT_MEMBER(integrator, int, use_caustics)
|
||||
/* Sampling pattern. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, sampling_pattern)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, tabulated_sobol_sequence_size)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, sobol_index_mask)
|
||||
KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE KERNEL_STRUCT_MEMBER(integrator, int, tabulated_sobol_sequence_size)
|
||||
KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE KERNEL_STRUCT_MEMBER(integrator, int, sobol_index_mask)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, scrambling_distance)
|
||||
/* Volume render. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, use_volumes)
|
||||
|
|
Loading…
Reference in New Issue