[Mesa-dev] [PATCH 07/13] mesa: reduce the size of gl_program
Marek Olšák
maraeo at gmail.com
Fri Feb 9 01:18:42 UTC 2018
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 15813cb..a73dcd4 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1416,25 +1416,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 f829fa3..c80d3b9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2161,21 +2161,21 @@ struct gl_program
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;
/** Subset of OutputsWritten outputs written with non-zero index. */
GLbitfield64 SecondaryOutputsWritten;
/** TEXTURE_x_BIT bitmask */
- GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+ GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
/** Bitfield of which samplers are used */
GLbitfield SamplersUsed;
/** Texture units used for shadow sampling. */
GLbitfield ShadowSamplers;
/** Texture units used for samplerExternalOES */
GLbitfield ExternalSamplersUsed;
/* Fragement shader only fields */
GLboolean OriginUpperLeft;
GLboolean PixelCenterInteger;
@@ -2239,21 +2239,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