Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/shaders/common_view_lib.glsl
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | |||||
| /* Temporary until we fully make the switch. */ | /* Temporary until we fully make the switch. */ | ||||
| #ifdef USE_GPU_SHADER_CREATE_INFO | #ifdef USE_GPU_SHADER_CREATE_INFO | ||||
| /* TODO(fclem): Rename PASS_RESOURCE_ID to DRW_RESOURCE_ID_VARYING_SET */ | /* TODO(fclem): Rename PASS_RESOURCE_ID to DRW_RESOURCE_ID_VARYING_SET */ | ||||
| # if defined(UNIFORM_RESOURCE_ID) | # if defined(UNIFORM_RESOURCE_ID) | ||||
| # define resource_id drw_ResourceID | # define resource_id drw_ResourceID | ||||
| # define PASS_RESOURCE_ID | # define PASS_RESOURCE_ID | ||||
| # elif defined(GPU_VERTEX_SHADER) | # elif defined(GPU_VERTEX_SHADER) | ||||
| # if defined(UNIFORM_RESOURCE_ID_NEW) | |||||
| # define resource_id drw_ResourceID | |||||
| # else | |||||
| # define resource_id gpu_InstanceIndex | # define resource_id gpu_InstanceIndex | ||||
| # endif | |||||
| # define PASS_RESOURCE_ID drw_ResourceID_iface.resource_index = resource_id; | # define PASS_RESOURCE_ID drw_ResourceID_iface.resource_index = resource_id; | ||||
| # elif defined(GPU_GEOMETRY_SHADER) | # elif defined(GPU_GEOMETRY_SHADER) | ||||
| # define resource_id drw_ResourceID_iface_in[0].index | # define resource_id drw_ResourceID_iface_in[0].index | ||||
| # define PASS_RESOURCE_ID drw_ResourceID_iface_out.resource_index = resource_id; | # define PASS_RESOURCE_ID drw_ResourceID_iface_out.resource_index = resource_id; | ||||
| # elif defined(GPU_FRAGMENT_SHADER) | # elif defined(GPU_FRAGMENT_SHADER) | ||||
| # define resource_id drw_ResourceID_iface.resource_index | # define resource_id drw_ResourceID_iface.resource_index | ||||
| Show All 31 Lines | |||||
| /* clang-format off */ | /* clang-format off */ | ||||
| #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && (!defined(OS_MAC) || defined(GPU_METAL)) && !defined(INSTANCED_ATTR) && !defined(DRW_LEGACY_MODEL_MATRIX) | #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && (!defined(OS_MAC) || defined(GPU_METAL)) && !defined(INSTANCED_ATTR) && !defined(DRW_LEGACY_MODEL_MATRIX) | ||||
| /* clang-format on */ | /* clang-format on */ | ||||
| /* Temporary until we fully make the switch. */ | /* Temporary until we fully make the switch. */ | ||||
| # ifndef DRW_SHADER_SHARED_H | # ifndef DRW_SHADER_SHARED_H | ||||
| struct ObjectMatrices { | struct ObjectMatrices { | ||||
| mat4 drw_modelMatrix; | mat4 model; | ||||
| mat4 drw_modelMatrixInverse; | mat4 model_inverse; | ||||
| }; | }; | ||||
| # endif /* DRW_SHADER_SHARED_H */ | # endif /* DRW_SHADER_SHARED_H */ | ||||
| # ifndef USE_GPU_SHADER_CREATE_INFO | # ifndef USE_GPU_SHADER_CREATE_INFO | ||||
| layout(std140) uniform modelBlock | layout(std140) uniform modelBlock | ||||
| { | { | ||||
| ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN]; | ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN]; | ||||
| }; | }; | ||||
| # define ModelMatrix (drw_matrices[resource_id].drw_modelMatrix) | # define ModelMatrix (drw_matrices[resource_id].model) | ||||
| # define ModelMatrixInverse (drw_matrices[resource_id].drw_modelMatrixInverse) | # define ModelMatrixInverse (drw_matrices[resource_id].model_inverse) | ||||
| # endif /* USE_GPU_SHADER_CREATE_INFO */ | # endif /* USE_GPU_SHADER_CREATE_INFO */ | ||||
| #else /* GPU_INTEL */ | #else /* GPU_INTEL */ | ||||
| /* Temporary until we fully make the switch. */ | /* Temporary until we fully make the switch. */ | ||||
| # ifndef USE_GPU_SHADER_CREATE_INFO | # ifndef USE_GPU_SHADER_CREATE_INFO | ||||
| /* Intel GPU seems to suffer performance impact when the model matrix is in UBO storage. | /* Intel GPU seems to suffer performance impact when the model matrix is in UBO storage. | ||||
| * So for now we just force using the legacy path. */ | * So for now we just force using the legacy path. */ | ||||
| ▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines | |||||