LONG MIDIFormat::dispatchMessage(USHORT usMsg, LONG lParam1, LONG lParam2) { switch (usMsg) { case MMIOM_GETFORMATINFO: return getFormatInfo((PMMFORMATINFO)lParam1); case MMIOM_GETFORMATNAME: return getFormatName((PSZ)lParam1, lParam2); case MMIOM_IDENTIFYFILE: return identifyFile((PSZ)lParam1, (HMMIO)lParam2); default: return defaultResponse(); } }
TestCase::IterateResult ReadPixelsTest::iterate (void) { // Create reference const int width = 13; const int height = 13; de::Random rnd(m_seed); tcu::TextureFormat format(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8); int pixelSize; GLint glFormat; GLint glType; getFormatInfo(format, glFormat, glType, pixelSize); m_testCtx.getLog() << tcu::TestLog::Message << "Format: " << glu::getPixelFormatStr(glFormat) << ", Type: " << glu::getTypeStr(glType) << tcu::TestLog::EndMessage; tcu::Texture2D reference(format, width, height); reference.allocLevel(0); GLU_CHECK_CALL(glViewport(0, 0, width, height)); // Clear color { const float red = rnd.getFloat(); const float green = rnd.getFloat(); const float blue = rnd.getFloat(); const float alpha = 1.0f; m_testCtx.getLog() << tcu::TestLog::Message << "Clear color: (" << red << ", " << green << ", " << blue << ", " << alpha << ")" << tcu::TestLog::EndMessage; // Clear target GLU_CHECK_CALL(glClearColor(red, green, blue, alpha)); GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT)); tcu::clear(reference.getLevel(0), tcu::Vec4(red, green, blue, alpha)); } render(reference); std::vector<deUint8> pixelData; const int rowPitch = m_alignment * deCeilFloatToInt32(pixelSize * width / (float)m_alignment); pixelData.resize(rowPitch * height, 0); GLU_CHECK_CALL(glPixelStorei(GL_PACK_ALIGNMENT, m_alignment)); GLU_CHECK_CALL(glReadPixels(0, 0, width, height, glFormat, glType, &(pixelData[0]))); if (m_context.getRenderTarget().getNumSamples() > 1) { const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format); const deUint8 redThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x())))); const deUint8 greenThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y())))); const deUint8 blueThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z())))); const deUint8 alphaThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w())))); // bilinearCompare only accepts RGBA, UINT8 tcu::Texture2D referenceRGBA8 (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), width, height); tcu::Texture2D resultRGBA8 (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), width, height); referenceRGBA8.allocLevel(0); resultRGBA8.allocLevel(0); tcu::copy(referenceRGBA8.getLevel(0), reference.getLevel(0)); tcu::copy(resultRGBA8.getLevel(0), tcu::PixelBufferAccess(format, width, height, 1, rowPitch, 0, &(pixelData[0]))); if (tcu::bilinearCompare(m_testCtx.getLog(), "Result", "Result", referenceRGBA8.getLevel(0), resultRGBA8.getLevel(0), tcu::RGBA(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT)) m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); else m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); } else { const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format); const float redThreshold = 2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x())); const float greenThreshold = 2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y())); const float blueThreshold = 2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z())); const float alphaThreshold = 2.0f / (1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w())); // Compare if (tcu::floatThresholdCompare(m_testCtx.getLog(), "Result", "Result", reference.getLevel(0), tcu::PixelBufferAccess(format, width, height, 1, rowPitch, 0, &(pixelData[0])), tcu::Vec4(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT)) m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); else m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); } return STOP; }