From 75be7fae1949a801c080530de53bdf123abb517a Mon Sep 17 00:00:00 2001 From: Pyry Haulos Date: Wed, 19 Nov 2014 15:26:10 -0800 Subject: [PATCH] Fix ambiguous mediump int write in shared_var.atomic tests Shaders in atomic memory functions were assigning mediump integers to SSBOs and expecting that those wouldn't get sign-extended in the process. Bug: 18446009 Change-Id: I10407cdb6558ba18a553df36285edf9d23239331 --- modules/gles31/functional/es31fShaderAtomicOpTests.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/gles31/functional/es31fShaderAtomicOpTests.cpp b/modules/gles31/functional/es31fShaderAtomicOpTests.cpp index 2758566..a962eeb 100644 --- a/modules/gles31/functional/es31fShaderAtomicOpTests.cpp +++ b/modules/gles31/functional/es31fShaderAtomicOpTests.cpp @@ -116,6 +116,10 @@ void ShaderAtomicOpCase::init (void) const bool isSSBO = m_operandType == ATOMIC_OPERAND_BUFFER_VARIABLE; const char* precName = getPrecisionName(m_precision); const char* typeName = getDataTypeName(m_type); + + const DataType outType = isSSBO ? m_type : glu::TYPE_UINT; + const char* outTypeName = getDataTypeName(outType); + const deUint32 numValues = product(m_workGroupSize)*product(m_numWorkGroups); std::ostringstream src; @@ -126,8 +130,8 @@ void ShaderAtomicOpCase::init (void) << "layout(binding = 0) buffer InOut\n" << "{\n" << " " << precName << " " << typeName << " inputValues[" << numValues << "];\n" - << " " << precName << " " << typeName << " outputValues[" << numValues << "];\n" - << " " << (isSSBO ? "coherent " : "") << precName << " " << typeName << " groupValues[" << product(m_numWorkGroups) << "];\n" + << " " << precName << " " << outTypeName << " outputValues[" << numValues << "];\n" + << " " << (isSSBO ? "coherent " : "") << precName << " " << outTypeName << " groupValues[" << product(m_numWorkGroups) << "];\n" << "} sb_inout;\n"; if (!isSSBO) @@ -144,17 +148,22 @@ void ShaderAtomicOpCase::init (void) if (isSSBO) { + DE_ASSERT(outType == m_type); src << " sb_inout.outputValues[offset] = " << m_funcName << "(sb_inout.groupValues[globalNdx], sb_inout.inputValues[offset]);\n"; } else { + const string castBeg = outType != m_type ? (string(outTypeName) + "(") : string(""); + const char* const castEnd = outType != m_type ? ")" : ""; + src << " if (gl_LocalInvocationIndex == 0u)\n" << " s_var = " << typeName << "(" << tcu::toHex(m_initialValue) << "u);\n" << " barrier();\n" - << " sb_inout.outputValues[offset] = " << m_funcName << "(s_var, sb_inout.inputValues[offset]);\n" + << " " << precName << " " << typeName << " res = " << m_funcName << "(s_var, sb_inout.inputValues[offset]);\n" + << " sb_inout.outputValues[offset] = " << castBeg << "res" << castEnd << ";\n" << " barrier();\n" << " if (gl_LocalInvocationIndex == 0u)\n" - << " sb_inout.groupValues[globalNdx] = s_var;\n"; + << " sb_inout.groupValues[globalNdx] = " << castBeg << "s_var" << castEnd << ";\n"; } src << "}\n"; -- 2.7.4