From ff5c4fec191755f6003d3da6545a3fd5c3a80e82 Mon Sep 17 00:00:00 2001 From: Yuly Novikov Date: Fri, 12 Jan 2018 17:01:48 -0500 Subject: [PATCH] Fix crash in ApplyLinkProgramExtra Access to i.ActiveResources.DefaultUniformBlock used to crash when glLinkProgram failed, because i.ActiveResources was null. --- gapis/api/gles/api/programs_and_shaders.api | 36 +++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/gapis/api/gles/api/programs_and_shaders.api b/gapis/api/gles/api/programs_and_shaders.api index 323107fdbb..98a540843b 100644 --- a/gapis/api/gles/api/programs_and_shaders.api +++ b/gapis/api/gles/api/programs_and_shaders.api @@ -140,25 +140,27 @@ sub void ApplyLinkProgramExtra(ref!Program p, ref!LinkProgramExtra i) { // Set uniform values to default (zeroed) p.UniformLocations = null - for _, uniformIndex, uniform in i.ActiveResources.DefaultUniformBlock { - elementInfo := GetUniformTypeInfo(uniform.Type) - elementSize := elementInfo.primitiveSize * elementInfo.vectorSize * elementInfo.vectorCount - values := make!u8(elementSize * as!u32(uniform.ArraySize)) - // Each element of the array is assigned a location by compiler. - // The location acts as a handle. Locations do not have to be consecutive. - for _, elementIndex, loc in uniform.Locations { - if (loc != -1) { - assert(elementIndex < as!u32(uniform.ArraySize)) - offset := elementIndex * elementSize - p.UniformLocations[as!UniformLocation(loc)] = Uniform( - Type: uniform.Type, - Value: values[offset:offset + elementSize], - Values: values[offset:len(values)], - UniformIndex: uniformIndex - ) + if i.LinkStatus == GL_TRUE { + for _, uniformIndex, uniform in i.ActiveResources.DefaultUniformBlock { + elementInfo := GetUniformTypeInfo(uniform.Type) + elementSize := elementInfo.primitiveSize * elementInfo.vectorSize * elementInfo.vectorCount + values := make!u8(elementSize * as!u32(uniform.ArraySize)) + // Each element of the array is assigned a location by compiler. + // The location acts as a handle. Locations do not have to be consecutive. + for _, elementIndex, loc in uniform.Locations { + if (loc != -1) { + assert(elementIndex < as!u32(uniform.ArraySize)) + offset := elementIndex * elementSize + p.UniformLocations[as!UniformLocation(loc)] = Uniform( + Type: uniform.Type, + Value: values[offset:offset + elementSize], + Values: values[offset:len(values)], + UniformIndex: uniformIndex + ) + } } + uniform.Value = values } - uniform.Value = values } } }