[Mesa-dev] [PATCH 12/20] mesa: reduce the size of gl_program
Marek Olšák
maraeo at gmail.com
Tue Nov 21 18:01:54 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
gl_program: 1456 -> 976 bytes
---
src/compiler/glsl/link_uniforms.cpp | 9 ++++-----
src/mesa/main/mtypes.h | 4 ++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 46c746b..1f254c7 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1413,25 +1413,24 @@ link_assign_uniform_storage(struct gl_context *ctx,
shader->Program->sh.NumBindlessImages = parcel.num_bindless_images;
shader->Program->sh.BindlessImages =
rzalloc_array(shader->Program, gl_bindless_image,
parcel.num_bindless_images);
for (unsigned j = 0; j < parcel.num_bindless_images; j++) {
shader->Program->sh.BindlessImages[j].access =
parcel.bindless_access[j];
}
}
- STATIC_ASSERT(sizeof(shader->Program->sh.SamplerTargets) ==
- sizeof(parcel.targets));
- memcpy(shader->Program->sh.SamplerTargets,
- parcel.targets,
- sizeof(shader->Program->sh.SamplerTargets));
+ STATIC_ASSERT(ARRAY_SIZE(shader->Program->sh.SamplerTargets) ==
+ ARRAY_SIZE(parcel.targets));
+ for (unsigned j = 0; j < ARRAY_SIZE(parcel.targets); j++)
+ shader->Program->sh.SamplerTargets[j] = parcel.targets[j];
}
#ifndef NDEBUG
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
assert(prog->data->UniformStorage[i].storage != NULL ||
prog->data->UniformStorage[i].builtin ||
prog->data->UniformStorage[i].is_shader_storage ||
prog->data->UniformStorage[i].block_index != -1);
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 773fa57..f3e9839 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2104,21 +2104,21 @@ struct gl_program
/* Saved and restored with metadata. Freed with ralloc. */
void *driver_cache_blob;
size_t driver_cache_blob_size;
bool is_arb_asm; /** Is this an ARB assembly-style program */
/** Is this program written to on disk shader cache */
bool program_written_to_cache;
GLbitfield64 SecondaryOutputsWritten; /**< Subset of OutputsWritten outputs written with non-zero index. */
- GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
+ GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
GLbitfield ExternalSamplersUsed; /**< Texture units used for samplerExternalOES */
/* Fragement shader only fields */
GLboolean OriginUpperLeft;
GLboolean PixelCenterInteger;
/** Named parameters, constants, etc. from program text */
struct gl_program_parameter_list *Parameters;
@@ -2179,21 +2179,21 @@ struct gl_program
* \c gl_image_unit::Access for the corresponding image unit.
*/
GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
struct gl_uniform_block **UniformBlocks;
struct gl_uniform_block **ShaderStorageBlocks;
/** Which texture target is being sampled
* (TEXTURE_1D/2D/3D/etc_INDEX)
*/
- gl_texture_index SamplerTargets[MAX_SAMPLERS];
+ GLubyte SamplerTargets[MAX_SAMPLERS];
/**
* Number of samplers declared with the bindless_sampler layout
* qualifier as specified by ARB_bindless_texture.
*/
GLuint NumBindlessSamplers;
GLboolean HasBoundBindlessSampler;
struct gl_bindless_sampler *BindlessSamplers;
/**
--
2.7.4
More information about the mesa-dev
mailing list