1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core
3*35238bceSAndroid Build Coastguard Worker * ----------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Test Log C++ Wrapper.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "deCommandLine.h"
25*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
29*35238bceSAndroid Build Coastguard Worker
30*35238bceSAndroid Build Coastguard Worker #include <limits>
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker namespace tcu
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker class LogWriteFailedError : public ResourceError
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker public:
LogWriteFailedError(void)38*35238bceSAndroid Build Coastguard Worker LogWriteFailedError(void) : ResourceError("Writing to test log failed")
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker }
41*35238bceSAndroid Build Coastguard Worker };
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker enum
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker MAX_IMAGE_SIZE_2D = 4096,
46*35238bceSAndroid Build Coastguard Worker MAX_IMAGE_SIZE_3D = 128
47*35238bceSAndroid Build Coastguard Worker };
48*35238bceSAndroid Build Coastguard Worker
49*35238bceSAndroid Build Coastguard Worker // LogImage
50*35238bceSAndroid Build Coastguard Worker
LogImage(const std::string & name,const std::string & description,const Surface & surface,qpImageCompressionMode compression)51*35238bceSAndroid Build Coastguard Worker LogImage::LogImage(const std::string &name, const std::string &description, const Surface &surface,
52*35238bceSAndroid Build Coastguard Worker qpImageCompressionMode compression)
53*35238bceSAndroid Build Coastguard Worker : m_name(name)
54*35238bceSAndroid Build Coastguard Worker , m_description(description)
55*35238bceSAndroid Build Coastguard Worker , m_access(surface.getAccess())
56*35238bceSAndroid Build Coastguard Worker , m_scale(1.0f, 1.0f, 1.0f, 1.0f)
57*35238bceSAndroid Build Coastguard Worker , m_bias(0.0f, 0.0f, 0.0f, 0.0f)
58*35238bceSAndroid Build Coastguard Worker , m_compression(compression)
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker }
61*35238bceSAndroid Build Coastguard Worker
LogImage(const std::string & name,const std::string & description,const ConstPixelBufferAccess & access,qpImageCompressionMode compression)62*35238bceSAndroid Build Coastguard Worker LogImage::LogImage(const std::string &name, const std::string &description, const ConstPixelBufferAccess &access,
63*35238bceSAndroid Build Coastguard Worker qpImageCompressionMode compression)
64*35238bceSAndroid Build Coastguard Worker : m_name(name)
65*35238bceSAndroid Build Coastguard Worker , m_description(description)
66*35238bceSAndroid Build Coastguard Worker , m_access(access)
67*35238bceSAndroid Build Coastguard Worker , m_scale(1.0f, 1.0f, 1.0f, 1.0f)
68*35238bceSAndroid Build Coastguard Worker , m_bias(0.0f, 0.0f, 0.0f, 0.0f)
69*35238bceSAndroid Build Coastguard Worker , m_compression(compression)
70*35238bceSAndroid Build Coastguard Worker {
71*35238bceSAndroid Build Coastguard Worker // Simplify combined formats that only use a single channel
72*35238bceSAndroid Build Coastguard Worker if (tcu::isCombinedDepthStencilType(m_access.getFormat().type))
73*35238bceSAndroid Build Coastguard Worker {
74*35238bceSAndroid Build Coastguard Worker if (m_access.getFormat().order == tcu::TextureFormat::D)
75*35238bceSAndroid Build Coastguard Worker m_access = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
76*35238bceSAndroid Build Coastguard Worker else if (m_access.getFormat().order == tcu::TextureFormat::S)
77*35238bceSAndroid Build Coastguard Worker m_access = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
78*35238bceSAndroid Build Coastguard Worker }
79*35238bceSAndroid Build Coastguard Worker
80*35238bceSAndroid Build Coastguard Worker // Implicit scale and bias
81*35238bceSAndroid Build Coastguard Worker if (m_access.getFormat().order != tcu::TextureFormat::DS)
82*35238bceSAndroid Build Coastguard Worker computePixelScaleBias(m_access, m_scale, m_bias);
83*35238bceSAndroid Build Coastguard Worker else
84*35238bceSAndroid Build Coastguard Worker {
85*35238bceSAndroid Build Coastguard Worker // Pack D and S bias and scale to R and G
86*35238bceSAndroid Build Coastguard Worker const ConstPixelBufferAccess depthAccess =
87*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
88*35238bceSAndroid Build Coastguard Worker const ConstPixelBufferAccess stencilAccess =
89*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
90*35238bceSAndroid Build Coastguard Worker tcu::Vec4 depthScale;
91*35238bceSAndroid Build Coastguard Worker tcu::Vec4 depthBias;
92*35238bceSAndroid Build Coastguard Worker tcu::Vec4 stencilScale;
93*35238bceSAndroid Build Coastguard Worker tcu::Vec4 stencilBias;
94*35238bceSAndroid Build Coastguard Worker
95*35238bceSAndroid Build Coastguard Worker computePixelScaleBias(depthAccess, depthScale, depthBias);
96*35238bceSAndroid Build Coastguard Worker computePixelScaleBias(stencilAccess, stencilScale, stencilBias);
97*35238bceSAndroid Build Coastguard Worker
98*35238bceSAndroid Build Coastguard Worker m_scale = tcu::Vec4(depthScale.x(), stencilScale.x(), 0.0f, 0.0f);
99*35238bceSAndroid Build Coastguard Worker m_bias = tcu::Vec4(depthBias.x(), stencilBias.x(), 0.0f, 0.0f);
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker
LogImage(const std::string & name,const std::string & description,const ConstPixelBufferAccess & access,const Vec4 & scale,const Vec4 & bias,qpImageCompressionMode compression)103*35238bceSAndroid Build Coastguard Worker LogImage::LogImage(const std::string &name, const std::string &description, const ConstPixelBufferAccess &access,
104*35238bceSAndroid Build Coastguard Worker const Vec4 &scale, const Vec4 &bias, qpImageCompressionMode compression)
105*35238bceSAndroid Build Coastguard Worker : m_name(name)
106*35238bceSAndroid Build Coastguard Worker , m_description(description)
107*35238bceSAndroid Build Coastguard Worker , m_access(access)
108*35238bceSAndroid Build Coastguard Worker , m_scale(scale)
109*35238bceSAndroid Build Coastguard Worker , m_bias(bias)
110*35238bceSAndroid Build Coastguard Worker , m_compression(compression)
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker // Cannot set scale and bias of combined formats
113*35238bceSAndroid Build Coastguard Worker DE_ASSERT(access.getFormat().order != tcu::TextureFormat::DS);
114*35238bceSAndroid Build Coastguard Worker
115*35238bceSAndroid Build Coastguard Worker // Simplify access
116*35238bceSAndroid Build Coastguard Worker if (tcu::isCombinedDepthStencilType(access.getFormat().type))
117*35238bceSAndroid Build Coastguard Worker {
118*35238bceSAndroid Build Coastguard Worker if (access.getFormat().order == tcu::TextureFormat::D)
119*35238bceSAndroid Build Coastguard Worker m_access = tcu::getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_DEPTH);
120*35238bceSAndroid Build Coastguard Worker if (access.getFormat().order == tcu::TextureFormat::S)
121*35238bceSAndroid Build Coastguard Worker m_access = tcu::getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_STENCIL);
122*35238bceSAndroid Build Coastguard Worker else
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker // Cannot log a DS format
125*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
126*35238bceSAndroid Build Coastguard Worker return;
127*35238bceSAndroid Build Coastguard Worker }
128*35238bceSAndroid Build Coastguard Worker }
129*35238bceSAndroid Build Coastguard Worker }
130*35238bceSAndroid Build Coastguard Worker
write(TestLog & log) const131*35238bceSAndroid Build Coastguard Worker void LogImage::write(TestLog &log) const
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker if (m_access.getFormat().order != tcu::TextureFormat::DS)
134*35238bceSAndroid Build Coastguard Worker log.writeImage(m_name.c_str(), m_description.c_str(), m_access, m_scale, m_bias, m_compression);
135*35238bceSAndroid Build Coastguard Worker else
136*35238bceSAndroid Build Coastguard Worker {
137*35238bceSAndroid Build Coastguard Worker const ConstPixelBufferAccess depthAccess =
138*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
139*35238bceSAndroid Build Coastguard Worker const ConstPixelBufferAccess stencilAccess =
140*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
141*35238bceSAndroid Build Coastguard Worker
142*35238bceSAndroid Build Coastguard Worker log.startImageSet(m_name.c_str(), m_description.c_str());
143*35238bceSAndroid Build Coastguard Worker log.writeImage("Depth", "Depth channel", depthAccess, m_scale.swizzle(0, 0, 0, 0), m_bias.swizzle(0, 0, 0, 0),
144*35238bceSAndroid Build Coastguard Worker m_compression);
145*35238bceSAndroid Build Coastguard Worker log.writeImage("Stencil", "Stencil channel", stencilAccess, m_scale.swizzle(1, 1, 1, 1),
146*35238bceSAndroid Build Coastguard Worker m_bias.swizzle(1, 1, 1, 1), m_compression);
147*35238bceSAndroid Build Coastguard Worker log.endImageSet();
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker }
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker // MessageBuilder
152*35238bceSAndroid Build Coastguard Worker
MessageBuilder(const MessageBuilder & other)153*35238bceSAndroid Build Coastguard Worker MessageBuilder::MessageBuilder(const MessageBuilder &other) : m_log(other.m_log)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker m_str.str(other.m_str.str());
156*35238bceSAndroid Build Coastguard Worker }
157*35238bceSAndroid Build Coastguard Worker
operator =(const MessageBuilder & other)158*35238bceSAndroid Build Coastguard Worker MessageBuilder &MessageBuilder::operator=(const MessageBuilder &other)
159*35238bceSAndroid Build Coastguard Worker {
160*35238bceSAndroid Build Coastguard Worker m_log = other.m_log;
161*35238bceSAndroid Build Coastguard Worker m_str.str(other.m_str.str());
162*35238bceSAndroid Build Coastguard Worker return *this;
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker
operator <<(const TestLog::EndMessageToken &)165*35238bceSAndroid Build Coastguard Worker TestLog &MessageBuilder::operator<<(const TestLog::EndMessageToken &)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker m_log->writeMessage(m_str.str().c_str());
168*35238bceSAndroid Build Coastguard Worker return *m_log;
169*35238bceSAndroid Build Coastguard Worker }
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker // SampleBuilder
172*35238bceSAndroid Build Coastguard Worker
operator <<(const TestLog::EndSampleToken &)173*35238bceSAndroid Build Coastguard Worker TestLog &SampleBuilder::operator<<(const TestLog::EndSampleToken &)
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker m_log->startSample();
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker for (std::vector<Value>::const_iterator val = m_values.begin(); val != m_values.end(); ++val)
178*35238bceSAndroid Build Coastguard Worker {
179*35238bceSAndroid Build Coastguard Worker if (val->type == Value::TYPE_FLOAT64)
180*35238bceSAndroid Build Coastguard Worker m_log->writeSampleValue(val->value.float64);
181*35238bceSAndroid Build Coastguard Worker else if (val->type == Value::TYPE_INT64)
182*35238bceSAndroid Build Coastguard Worker m_log->writeSampleValue(val->value.int64);
183*35238bceSAndroid Build Coastguard Worker else
184*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
185*35238bceSAndroid Build Coastguard Worker }
186*35238bceSAndroid Build Coastguard Worker
187*35238bceSAndroid Build Coastguard Worker m_log->endSample();
188*35238bceSAndroid Build Coastguard Worker
189*35238bceSAndroid Build Coastguard Worker return *m_log;
190*35238bceSAndroid Build Coastguard Worker }
191*35238bceSAndroid Build Coastguard Worker
192*35238bceSAndroid Build Coastguard Worker // TestLog
193*35238bceSAndroid Build Coastguard Worker
TestLog(const char * fileName,uint32_t flags)194*35238bceSAndroid Build Coastguard Worker TestLog::TestLog(const char *fileName, uint32_t flags)
195*35238bceSAndroid Build Coastguard Worker : m_log(qpTestLog_createFileLog(fileName, flags))
196*35238bceSAndroid Build Coastguard Worker , m_logSupressed(false)
197*35238bceSAndroid Build Coastguard Worker {
198*35238bceSAndroid Build Coastguard Worker if (!m_log)
199*35238bceSAndroid Build Coastguard Worker throw ResourceError(std::string("Failed to open test log file '") + fileName + "'");
200*35238bceSAndroid Build Coastguard Worker }
201*35238bceSAndroid Build Coastguard Worker
writeSessionInfo(std::string additionalInfo)202*35238bceSAndroid Build Coastguard Worker void TestLog::writeSessionInfo(std::string additionalInfo)
203*35238bceSAndroid Build Coastguard Worker {
204*35238bceSAndroid Build Coastguard Worker qpTestLog_beginSession(m_log, additionalInfo.c_str());
205*35238bceSAndroid Build Coastguard Worker }
206*35238bceSAndroid Build Coastguard Worker
~TestLog(void)207*35238bceSAndroid Build Coastguard Worker TestLog::~TestLog(void)
208*35238bceSAndroid Build Coastguard Worker {
209*35238bceSAndroid Build Coastguard Worker qpTestLog_destroy(m_log);
210*35238bceSAndroid Build Coastguard Worker }
211*35238bceSAndroid Build Coastguard Worker
writeMessage(const char * msgStr)212*35238bceSAndroid Build Coastguard Worker void TestLog::writeMessage(const char *msgStr)
213*35238bceSAndroid Build Coastguard Worker {
214*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
215*35238bceSAndroid Build Coastguard Worker return;
216*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
217*35238bceSAndroid Build Coastguard Worker return;
218*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeText(m_log, DE_NULL, DE_NULL, QP_KEY_TAG_NONE, msgStr) == false)
219*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker
startImageSet(const char * name,const char * description)222*35238bceSAndroid Build Coastguard Worker void TestLog::startImageSet(const char *name, const char *description)
223*35238bceSAndroid Build Coastguard Worker {
224*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
225*35238bceSAndroid Build Coastguard Worker return;
226*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
227*35238bceSAndroid Build Coastguard Worker return;
228*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startImageSet(m_log, name, description) == false)
229*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
230*35238bceSAndroid Build Coastguard Worker }
231*35238bceSAndroid Build Coastguard Worker
endImageSet(void)232*35238bceSAndroid Build Coastguard Worker void TestLog::endImageSet(void)
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
235*35238bceSAndroid Build Coastguard Worker return;
236*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
237*35238bceSAndroid Build Coastguard Worker return;
238*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endImageSet(m_log) == false)
239*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
240*35238bceSAndroid Build Coastguard Worker }
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker template <int Size>
computeScaledSize(const Vector<int,Size> & imageSize,int maxSize)243*35238bceSAndroid Build Coastguard Worker static Vector<int, Size> computeScaledSize(const Vector<int, Size> &imageSize, int maxSize)
244*35238bceSAndroid Build Coastguard Worker {
245*35238bceSAndroid Build Coastguard Worker bool allInRange = true;
246*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < Size; i++)
247*35238bceSAndroid Build Coastguard Worker allInRange = allInRange && (imageSize[i] <= maxSize);
248*35238bceSAndroid Build Coastguard Worker
249*35238bceSAndroid Build Coastguard Worker if (allInRange)
250*35238bceSAndroid Build Coastguard Worker return imageSize;
251*35238bceSAndroid Build Coastguard Worker else
252*35238bceSAndroid Build Coastguard Worker {
253*35238bceSAndroid Build Coastguard Worker float d = 1.0f;
254*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < Size; i++)
255*35238bceSAndroid Build Coastguard Worker d = de::max(d, (float)imageSize[i] / (float)maxSize);
256*35238bceSAndroid Build Coastguard Worker
257*35238bceSAndroid Build Coastguard Worker Vector<int, Size> res;
258*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < Size; i++)
259*35238bceSAndroid Build Coastguard Worker res[i] = de::max(1, deRoundFloatToInt32((float)imageSize[i] / d));
260*35238bceSAndroid Build Coastguard Worker
261*35238bceSAndroid Build Coastguard Worker return res;
262*35238bceSAndroid Build Coastguard Worker }
263*35238bceSAndroid Build Coastguard Worker }
264*35238bceSAndroid Build Coastguard Worker
writeImage(const char * name,const char * description,const ConstPixelBufferAccess & access,const Vec4 & pixelScale,const Vec4 & pixelBias,qpImageCompressionMode compressionMode)265*35238bceSAndroid Build Coastguard Worker void TestLog::writeImage(const char *name, const char *description, const ConstPixelBufferAccess &access,
266*35238bceSAndroid Build Coastguard Worker const Vec4 &pixelScale, const Vec4 &pixelBias, qpImageCompressionMode compressionMode)
267*35238bceSAndroid Build Coastguard Worker {
268*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
269*35238bceSAndroid Build Coastguard Worker return;
270*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
271*35238bceSAndroid Build Coastguard Worker return;
272*35238bceSAndroid Build Coastguard Worker const TextureFormat &format = access.getFormat();
273*35238bceSAndroid Build Coastguard Worker int width = access.getWidth();
274*35238bceSAndroid Build Coastguard Worker int height = access.getHeight();
275*35238bceSAndroid Build Coastguard Worker int depth = access.getDepth();
276*35238bceSAndroid Build Coastguard Worker
277*35238bceSAndroid Build Coastguard Worker // Writing a combined image does not make sense
278*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!tcu::isCombinedDepthStencilType(access.getFormat().type));
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker // Do not bother with preprocessing if images are not stored
281*35238bceSAndroid Build Coastguard Worker if ((qpTestLog_getLogFlags(m_log) & QP_TEST_LOG_EXCLUDE_IMAGES) != 0)
282*35238bceSAndroid Build Coastguard Worker return;
283*35238bceSAndroid Build Coastguard Worker
284*35238bceSAndroid Build Coastguard Worker if (depth == 1 && (format.type == TextureFormat::UNORM_INT8 || format.type == TextureFormat::UNSIGNED_INT8) &&
285*35238bceSAndroid Build Coastguard Worker width <= MAX_IMAGE_SIZE_2D && height <= MAX_IMAGE_SIZE_2D &&
286*35238bceSAndroid Build Coastguard Worker (format.order == TextureFormat::RGB || format.order == TextureFormat::RGBA) &&
287*35238bceSAndroid Build Coastguard Worker access.getPixelPitch() == access.getFormat().getPixelSize() && pixelBias[0] == 0.0f && pixelBias[1] == 0.0f &&
288*35238bceSAndroid Build Coastguard Worker pixelBias[2] == 0.0f && pixelBias[3] == 0.0f && pixelScale[0] == 1.0f && pixelScale[1] == 1.0f &&
289*35238bceSAndroid Build Coastguard Worker pixelScale[2] == 1.0f && pixelScale[3] == 1.0f)
290*35238bceSAndroid Build Coastguard Worker {
291*35238bceSAndroid Build Coastguard Worker // Fast-path.
292*35238bceSAndroid Build Coastguard Worker bool isRGBA = format.order == TextureFormat::RGBA;
293*35238bceSAndroid Build Coastguard Worker
294*35238bceSAndroid Build Coastguard Worker writeImage(name, description, compressionMode, isRGBA ? QP_IMAGE_FORMAT_RGBA8888 : QP_IMAGE_FORMAT_RGB888,
295*35238bceSAndroid Build Coastguard Worker width, height, access.getRowPitch(), access.getDataPtr());
296*35238bceSAndroid Build Coastguard Worker }
297*35238bceSAndroid Build Coastguard Worker else if (depth == 1)
298*35238bceSAndroid Build Coastguard Worker {
299*35238bceSAndroid Build Coastguard Worker Sampler sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::LINEAR,
300*35238bceSAndroid Build Coastguard Worker Sampler::NEAREST);
301*35238bceSAndroid Build Coastguard Worker IVec2 logImageSize = computeScaledSize(IVec2(width, height), MAX_IMAGE_SIZE_2D);
302*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel logImage(TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8), logImageSize.x(),
303*35238bceSAndroid Build Coastguard Worker logImageSize.y(), 1);
304*35238bceSAndroid Build Coastguard Worker PixelBufferAccess logImageAccess = logImage.getAccess();
305*35238bceSAndroid Build Coastguard Worker std::ostringstream longDesc;
306*35238bceSAndroid Build Coastguard Worker
307*35238bceSAndroid Build Coastguard Worker longDesc << description << " (p' = p * " << pixelScale << " + " << pixelBias << ")";
308*35238bceSAndroid Build Coastguard Worker
309*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < logImage.getHeight(); y++)
310*35238bceSAndroid Build Coastguard Worker {
311*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < logImage.getWidth(); x++)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker float yf = ((float)y + 0.5f) / (float)logImage.getHeight();
314*35238bceSAndroid Build Coastguard Worker float xf = ((float)x + 0.5f) / (float)logImage.getWidth();
315*35238bceSAndroid Build Coastguard Worker Vec4 s = access.sample2D(sampler, sampler.minFilter, xf, yf, 0) * pixelScale + pixelBias;
316*35238bceSAndroid Build Coastguard Worker
317*35238bceSAndroid Build Coastguard Worker logImageAccess.setPixel(s, x, y);
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker }
320*35238bceSAndroid Build Coastguard Worker
321*35238bceSAndroid Build Coastguard Worker writeImage(name, longDesc.str().c_str(), compressionMode, QP_IMAGE_FORMAT_RGBA8888, logImageAccess.getWidth(),
322*35238bceSAndroid Build Coastguard Worker logImageAccess.getHeight(), logImageAccess.getRowPitch(), logImageAccess.getDataPtr());
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker else
325*35238bceSAndroid Build Coastguard Worker {
326*35238bceSAndroid Build Coastguard Worker // Isometric splat volume rendering.
327*35238bceSAndroid Build Coastguard Worker const float blendFactor = 0.85f;
328*35238bceSAndroid Build Coastguard Worker IVec3 scaledSize = computeScaledSize(IVec3(width, height, depth), MAX_IMAGE_SIZE_3D);
329*35238bceSAndroid Build Coastguard Worker int w = scaledSize.x();
330*35238bceSAndroid Build Coastguard Worker int h = scaledSize.y();
331*35238bceSAndroid Build Coastguard Worker int d = scaledSize.z();
332*35238bceSAndroid Build Coastguard Worker int logImageW = w + d - 1;
333*35238bceSAndroid Build Coastguard Worker int logImageH = w + d + h;
334*35238bceSAndroid Build Coastguard Worker std::vector<float> blendImage(logImageW * logImageH * 4, 0.0f);
335*35238bceSAndroid Build Coastguard Worker PixelBufferAccess blendImageAccess(TextureFormat(TextureFormat::RGBA, TextureFormat::FLOAT), logImageW,
336*35238bceSAndroid Build Coastguard Worker logImageH, 1, &blendImage[0]);
337*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel logImage(TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8), logImageW, logImageH,
338*35238bceSAndroid Build Coastguard Worker 1);
339*35238bceSAndroid Build Coastguard Worker PixelBufferAccess logImageAccess = logImage.getAccess();
340*35238bceSAndroid Build Coastguard Worker Sampler sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST,
341*35238bceSAndroid Build Coastguard Worker Sampler::NEAREST);
342*35238bceSAndroid Build Coastguard Worker std::ostringstream longDesc;
343*35238bceSAndroid Build Coastguard Worker
344*35238bceSAndroid Build Coastguard Worker // \note Back-to-front.
345*35238bceSAndroid Build Coastguard Worker for (int z = d - 1; z >= 0; z--)
346*35238bceSAndroid Build Coastguard Worker {
347*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < h; y++)
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < w; x++)
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker int px = w - (x + 1) + z;
352*35238bceSAndroid Build Coastguard Worker int py = (w + d + h) - (x + y + z + 1);
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker float xf = ((float)x + 0.5f) / (float)w;
355*35238bceSAndroid Build Coastguard Worker float yf = ((float)y + 0.5f) / (float)h;
356*35238bceSAndroid Build Coastguard Worker float zf = ((float)z + 0.5f) / (float)d;
357*35238bceSAndroid Build Coastguard Worker
358*35238bceSAndroid Build Coastguard Worker Vec4 p = blendImageAccess.getPixel(px, py);
359*35238bceSAndroid Build Coastguard Worker Vec4 s = access.sample3D(sampler, sampler.minFilter, xf, yf, zf);
360*35238bceSAndroid Build Coastguard Worker Vec4 b = s + p * blendFactor;
361*35238bceSAndroid Build Coastguard Worker
362*35238bceSAndroid Build Coastguard Worker blendImageAccess.setPixel(b, px, py);
363*35238bceSAndroid Build Coastguard Worker }
364*35238bceSAndroid Build Coastguard Worker }
365*35238bceSAndroid Build Coastguard Worker }
366*35238bceSAndroid Build Coastguard Worker
367*35238bceSAndroid Build Coastguard Worker // Scale blend image nicely.
368*35238bceSAndroid Build Coastguard Worker longDesc << description << " (p' = p * " << pixelScale << " + " << pixelBias << ")";
369*35238bceSAndroid Build Coastguard Worker
370*35238bceSAndroid Build Coastguard Worker // Write to final image.
371*35238bceSAndroid Build Coastguard Worker tcu::clear(logImageAccess, tcu::IVec4(0x33, 0x66, 0x99, 0xff));
372*35238bceSAndroid Build Coastguard Worker
373*35238bceSAndroid Build Coastguard Worker for (int z = 0; z < d; z++)
374*35238bceSAndroid Build Coastguard Worker {
375*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < h; y++)
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < w; x++)
378*35238bceSAndroid Build Coastguard Worker {
379*35238bceSAndroid Build Coastguard Worker if (z != 0 && !(x == 0 || y == h - 1 || y == h - 2))
380*35238bceSAndroid Build Coastguard Worker continue;
381*35238bceSAndroid Build Coastguard Worker
382*35238bceSAndroid Build Coastguard Worker int px = w - (x + 1) + z;
383*35238bceSAndroid Build Coastguard Worker int py = (w + d + h) - (x + y + z + 1);
384*35238bceSAndroid Build Coastguard Worker Vec4 s = blendImageAccess.getPixel(px, py) * pixelScale + pixelBias;
385*35238bceSAndroid Build Coastguard Worker
386*35238bceSAndroid Build Coastguard Worker logImageAccess.setPixel(s, px, py);
387*35238bceSAndroid Build Coastguard Worker }
388*35238bceSAndroid Build Coastguard Worker }
389*35238bceSAndroid Build Coastguard Worker }
390*35238bceSAndroid Build Coastguard Worker
391*35238bceSAndroid Build Coastguard Worker writeImage(name, longDesc.str().c_str(), compressionMode, QP_IMAGE_FORMAT_RGBA8888, logImageAccess.getWidth(),
392*35238bceSAndroid Build Coastguard Worker logImageAccess.getHeight(), logImageAccess.getRowPitch(), logImageAccess.getDataPtr());
393*35238bceSAndroid Build Coastguard Worker }
394*35238bceSAndroid Build Coastguard Worker }
395*35238bceSAndroid Build Coastguard Worker
writeImage(const char * name,const char * description,qpImageCompressionMode compressionMode,qpImageFormat format,int width,int height,int stride,const void * data)396*35238bceSAndroid Build Coastguard Worker void TestLog::writeImage(const char *name, const char *description, qpImageCompressionMode compressionMode,
397*35238bceSAndroid Build Coastguard Worker qpImageFormat format, int width, int height, int stride, const void *data)
398*35238bceSAndroid Build Coastguard Worker {
399*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
400*35238bceSAndroid Build Coastguard Worker return;
401*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
402*35238bceSAndroid Build Coastguard Worker return;
403*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeImage(m_log, name, description, compressionMode, format, width, height, stride, data) == false)
404*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
405*35238bceSAndroid Build Coastguard Worker }
406*35238bceSAndroid Build Coastguard Worker
startSection(const char * name,const char * description)407*35238bceSAndroid Build Coastguard Worker void TestLog::startSection(const char *name, const char *description)
408*35238bceSAndroid Build Coastguard Worker {
409*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
410*35238bceSAndroid Build Coastguard Worker return;
411*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
412*35238bceSAndroid Build Coastguard Worker return;
413*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startSection(m_log, name, description) == false)
414*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker
endSection(void)417*35238bceSAndroid Build Coastguard Worker void TestLog::endSection(void)
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
420*35238bceSAndroid Build Coastguard Worker return;
421*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
422*35238bceSAndroid Build Coastguard Worker return;
423*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endSection(m_log) == false)
424*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
425*35238bceSAndroid Build Coastguard Worker }
426*35238bceSAndroid Build Coastguard Worker
startShaderProgram(bool linkOk,const char * linkInfoLog)427*35238bceSAndroid Build Coastguard Worker void TestLog::startShaderProgram(bool linkOk, const char *linkInfoLog)
428*35238bceSAndroid Build Coastguard Worker {
429*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
430*35238bceSAndroid Build Coastguard Worker return;
431*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
432*35238bceSAndroid Build Coastguard Worker return;
433*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startShaderProgram(m_log, linkOk ? true : false, linkInfoLog) == false)
434*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker
endShaderProgram(void)437*35238bceSAndroid Build Coastguard Worker void TestLog::endShaderProgram(void)
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
440*35238bceSAndroid Build Coastguard Worker return;
441*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
442*35238bceSAndroid Build Coastguard Worker return;
443*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endShaderProgram(m_log) == false)
444*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
445*35238bceSAndroid Build Coastguard Worker }
446*35238bceSAndroid Build Coastguard Worker
writeShader(qpShaderType type,const char * source,bool compileOk,const char * infoLog)447*35238bceSAndroid Build Coastguard Worker void TestLog::writeShader(qpShaderType type, const char *source, bool compileOk, const char *infoLog)
448*35238bceSAndroid Build Coastguard Worker {
449*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
450*35238bceSAndroid Build Coastguard Worker return;
451*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
452*35238bceSAndroid Build Coastguard Worker return;
453*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeShader(m_log, type, source, compileOk ? true : false, infoLog) == false)
454*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
455*35238bceSAndroid Build Coastguard Worker }
456*35238bceSAndroid Build Coastguard Worker
writeSpirVAssemblySource(const char * source)457*35238bceSAndroid Build Coastguard Worker void TestLog::writeSpirVAssemblySource(const char *source)
458*35238bceSAndroid Build Coastguard Worker {
459*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
460*35238bceSAndroid Build Coastguard Worker return;
461*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
462*35238bceSAndroid Build Coastguard Worker return;
463*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeSpirVAssemblySource(m_log, source) == false)
464*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
465*35238bceSAndroid Build Coastguard Worker }
466*35238bceSAndroid Build Coastguard Worker
writeKernelSource(const char * source)467*35238bceSAndroid Build Coastguard Worker void TestLog::writeKernelSource(const char *source)
468*35238bceSAndroid Build Coastguard Worker {
469*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
470*35238bceSAndroid Build Coastguard Worker return;
471*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
472*35238bceSAndroid Build Coastguard Worker return;
473*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeKernelSource(m_log, source) == false)
474*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
475*35238bceSAndroid Build Coastguard Worker }
476*35238bceSAndroid Build Coastguard Worker
writeCompileInfo(const char * name,const char * description,bool compileOk,const char * infoLog)477*35238bceSAndroid Build Coastguard Worker void TestLog::writeCompileInfo(const char *name, const char *description, bool compileOk, const char *infoLog)
478*35238bceSAndroid Build Coastguard Worker {
479*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
480*35238bceSAndroid Build Coastguard Worker return;
481*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
482*35238bceSAndroid Build Coastguard Worker return;
483*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeCompileInfo(m_log, name, description, compileOk ? true : false, infoLog) == false)
484*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
485*35238bceSAndroid Build Coastguard Worker }
486*35238bceSAndroid Build Coastguard Worker
writeFloat(const char * name,const char * description,const char * unit,qpKeyValueTag tag,float value)487*35238bceSAndroid Build Coastguard Worker void TestLog::writeFloat(const char *name, const char *description, const char *unit, qpKeyValueTag tag, float value)
488*35238bceSAndroid Build Coastguard Worker {
489*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
490*35238bceSAndroid Build Coastguard Worker return;
491*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
492*35238bceSAndroid Build Coastguard Worker return;
493*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeFloat(m_log, name, description, unit, tag, value) == false)
494*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
495*35238bceSAndroid Build Coastguard Worker }
496*35238bceSAndroid Build Coastguard Worker
writeInteger(const char * name,const char * description,const char * unit,qpKeyValueTag tag,int64_t value)497*35238bceSAndroid Build Coastguard Worker void TestLog::writeInteger(const char *name, const char *description, const char *unit, qpKeyValueTag tag,
498*35238bceSAndroid Build Coastguard Worker int64_t value)
499*35238bceSAndroid Build Coastguard Worker {
500*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
501*35238bceSAndroid Build Coastguard Worker return;
502*35238bceSAndroid Build Coastguard Worker if (m_skipAdditionalDataInLog)
503*35238bceSAndroid Build Coastguard Worker return;
504*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeInteger(m_log, name, description, unit, tag, value) == false)
505*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
506*35238bceSAndroid Build Coastguard Worker }
507*35238bceSAndroid Build Coastguard Worker
startEglConfigSet(const char * name,const char * description)508*35238bceSAndroid Build Coastguard Worker void TestLog::startEglConfigSet(const char *name, const char *description)
509*35238bceSAndroid Build Coastguard Worker {
510*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
511*35238bceSAndroid Build Coastguard Worker return;
512*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startEglConfigSet(m_log, name, description) == false)
513*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
514*35238bceSAndroid Build Coastguard Worker }
515*35238bceSAndroid Build Coastguard Worker
writeEglConfig(const qpEglConfigInfo * config)516*35238bceSAndroid Build Coastguard Worker void TestLog::writeEglConfig(const qpEglConfigInfo *config)
517*35238bceSAndroid Build Coastguard Worker {
518*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
519*35238bceSAndroid Build Coastguard Worker return;
520*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeEglConfig(m_log, config) == false)
521*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
522*35238bceSAndroid Build Coastguard Worker }
523*35238bceSAndroid Build Coastguard Worker
endEglConfigSet(void)524*35238bceSAndroid Build Coastguard Worker void TestLog::endEglConfigSet(void)
525*35238bceSAndroid Build Coastguard Worker {
526*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
527*35238bceSAndroid Build Coastguard Worker return;
528*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endEglConfigSet(m_log) == false)
529*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker
startCase(const char * testCasePath,qpTestCaseType testCaseType)532*35238bceSAndroid Build Coastguard Worker void TestLog::startCase(const char *testCasePath, qpTestCaseType testCaseType)
533*35238bceSAndroid Build Coastguard Worker {
534*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
535*35238bceSAndroid Build Coastguard Worker return;
536*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startCase(m_log, testCasePath, testCaseType) == false)
537*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
538*35238bceSAndroid Build Coastguard Worker // Check if the test is one of those we want to print fully in the log
539*35238bceSAndroid Build Coastguard Worker m_skipAdditionalDataInLog = false;
540*35238bceSAndroid Build Coastguard Worker if (qpTestLog_isCompact(m_log))
541*35238bceSAndroid Build Coastguard Worker {
542*35238bceSAndroid Build Coastguard Worker const std::string testCasePathStr = testCasePath;
543*35238bceSAndroid Build Coastguard Worker if (testCasePathStr.rfind("dEQP-VK.info.") != 0 && testCasePathStr.rfind("dEQP-VK.api.info.") != 0 &&
544*35238bceSAndroid Build Coastguard Worker testCasePathStr.rfind("dEQP-VK.api.version_check.") != 0)
545*35238bceSAndroid Build Coastguard Worker {
546*35238bceSAndroid Build Coastguard Worker // We can skip writing text, numbers, imagesets, etc.
547*35238bceSAndroid Build Coastguard Worker m_skipAdditionalDataInLog = true;
548*35238bceSAndroid Build Coastguard Worker }
549*35238bceSAndroid Build Coastguard Worker }
550*35238bceSAndroid Build Coastguard Worker }
551*35238bceSAndroid Build Coastguard Worker
endCase(qpTestResult result,const char * description)552*35238bceSAndroid Build Coastguard Worker void TestLog::endCase(qpTestResult result, const char *description)
553*35238bceSAndroid Build Coastguard Worker {
554*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
555*35238bceSAndroid Build Coastguard Worker return;
556*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endCase(m_log, result, description) == false)
557*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
558*35238bceSAndroid Build Coastguard Worker }
559*35238bceSAndroid Build Coastguard Worker
terminateCase(qpTestResult result)560*35238bceSAndroid Build Coastguard Worker void TestLog::terminateCase(qpTestResult result)
561*35238bceSAndroid Build Coastguard Worker {
562*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
563*35238bceSAndroid Build Coastguard Worker return;
564*35238bceSAndroid Build Coastguard Worker if (qpTestLog_terminateCase(m_log, result) == false)
565*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
566*35238bceSAndroid Build Coastguard Worker }
567*35238bceSAndroid Build Coastguard Worker
startTestsCasesTime(void)568*35238bceSAndroid Build Coastguard Worker void TestLog::startTestsCasesTime(void)
569*35238bceSAndroid Build Coastguard Worker {
570*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
571*35238bceSAndroid Build Coastguard Worker return;
572*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startTestsCasesTime(m_log) == false)
573*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
574*35238bceSAndroid Build Coastguard Worker }
575*35238bceSAndroid Build Coastguard Worker
endTestsCasesTime(void)576*35238bceSAndroid Build Coastguard Worker void TestLog::endTestsCasesTime(void)
577*35238bceSAndroid Build Coastguard Worker {
578*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
579*35238bceSAndroid Build Coastguard Worker return;
580*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endTestsCasesTime(m_log) == false)
581*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
582*35238bceSAndroid Build Coastguard Worker }
583*35238bceSAndroid Build Coastguard Worker
startSampleList(const std::string & name,const std::string & description)584*35238bceSAndroid Build Coastguard Worker void TestLog::startSampleList(const std::string &name, const std::string &description)
585*35238bceSAndroid Build Coastguard Worker {
586*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
587*35238bceSAndroid Build Coastguard Worker return;
588*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startSampleList(m_log, name.c_str(), description.c_str()) == false)
589*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
590*35238bceSAndroid Build Coastguard Worker }
591*35238bceSAndroid Build Coastguard Worker
startSampleInfo(void)592*35238bceSAndroid Build Coastguard Worker void TestLog::startSampleInfo(void)
593*35238bceSAndroid Build Coastguard Worker {
594*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
595*35238bceSAndroid Build Coastguard Worker return;
596*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startSampleInfo(m_log) == false)
597*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
598*35238bceSAndroid Build Coastguard Worker }
599*35238bceSAndroid Build Coastguard Worker
writeValueInfo(const std::string & name,const std::string & description,const std::string & unit,qpSampleValueTag tag)600*35238bceSAndroid Build Coastguard Worker void TestLog::writeValueInfo(const std::string &name, const std::string &description, const std::string &unit,
601*35238bceSAndroid Build Coastguard Worker qpSampleValueTag tag)
602*35238bceSAndroid Build Coastguard Worker {
603*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
604*35238bceSAndroid Build Coastguard Worker return;
605*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeValueInfo(m_log, name.c_str(), description.c_str(), unit.empty() ? DE_NULL : unit.c_str(),
606*35238bceSAndroid Build Coastguard Worker tag) == false)
607*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
608*35238bceSAndroid Build Coastguard Worker }
609*35238bceSAndroid Build Coastguard Worker
endSampleInfo(void)610*35238bceSAndroid Build Coastguard Worker void TestLog::endSampleInfo(void)
611*35238bceSAndroid Build Coastguard Worker {
612*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
613*35238bceSAndroid Build Coastguard Worker return;
614*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endSampleInfo(m_log) == false)
615*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
616*35238bceSAndroid Build Coastguard Worker }
617*35238bceSAndroid Build Coastguard Worker
startSample(void)618*35238bceSAndroid Build Coastguard Worker void TestLog::startSample(void)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
621*35238bceSAndroid Build Coastguard Worker return;
622*35238bceSAndroid Build Coastguard Worker if (qpTestLog_startSample(m_log) == false)
623*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
624*35238bceSAndroid Build Coastguard Worker }
625*35238bceSAndroid Build Coastguard Worker
writeSampleValue(double value)626*35238bceSAndroid Build Coastguard Worker void TestLog::writeSampleValue(double value)
627*35238bceSAndroid Build Coastguard Worker {
628*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
629*35238bceSAndroid Build Coastguard Worker return;
630*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeValueFloat(m_log, value) == false)
631*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
632*35238bceSAndroid Build Coastguard Worker }
633*35238bceSAndroid Build Coastguard Worker
writeSampleValue(int64_t value)634*35238bceSAndroid Build Coastguard Worker void TestLog::writeSampleValue(int64_t value)
635*35238bceSAndroid Build Coastguard Worker {
636*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
637*35238bceSAndroid Build Coastguard Worker return;
638*35238bceSAndroid Build Coastguard Worker if (qpTestLog_writeValueInteger(m_log, value) == false)
639*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
640*35238bceSAndroid Build Coastguard Worker }
641*35238bceSAndroid Build Coastguard Worker
endSample(void)642*35238bceSAndroid Build Coastguard Worker void TestLog::endSample(void)
643*35238bceSAndroid Build Coastguard Worker {
644*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
645*35238bceSAndroid Build Coastguard Worker return;
646*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endSample(m_log) == false)
647*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
648*35238bceSAndroid Build Coastguard Worker }
649*35238bceSAndroid Build Coastguard Worker
endSampleList(void)650*35238bceSAndroid Build Coastguard Worker void TestLog::endSampleList(void)
651*35238bceSAndroid Build Coastguard Worker {
652*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
653*35238bceSAndroid Build Coastguard Worker return;
654*35238bceSAndroid Build Coastguard Worker if (qpTestLog_endSampleList(m_log) == false)
655*35238bceSAndroid Build Coastguard Worker throw LogWriteFailedError();
656*35238bceSAndroid Build Coastguard Worker }
657*35238bceSAndroid Build Coastguard Worker
writeRaw(const char * rawContents)658*35238bceSAndroid Build Coastguard Worker void TestLog::writeRaw(const char *rawContents)
659*35238bceSAndroid Build Coastguard Worker {
660*35238bceSAndroid Build Coastguard Worker if (m_logSupressed)
661*35238bceSAndroid Build Coastguard Worker return;
662*35238bceSAndroid Build Coastguard Worker qpTestLog_writeRaw(m_log, rawContents);
663*35238bceSAndroid Build Coastguard Worker }
664*35238bceSAndroid Build Coastguard Worker
isShaderLoggingEnabled(void)665*35238bceSAndroid Build Coastguard Worker bool TestLog::isShaderLoggingEnabled(void)
666*35238bceSAndroid Build Coastguard Worker {
667*35238bceSAndroid Build Coastguard Worker return (qpTestLog_getLogFlags(m_log) & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) == 0;
668*35238bceSAndroid Build Coastguard Worker }
669*35238bceSAndroid Build Coastguard Worker
supressLogging(bool value)670*35238bceSAndroid Build Coastguard Worker void TestLog::supressLogging(bool value)
671*35238bceSAndroid Build Coastguard Worker {
672*35238bceSAndroid Build Coastguard Worker m_logSupressed = value;
673*35238bceSAndroid Build Coastguard Worker }
674*35238bceSAndroid Build Coastguard Worker
isSupressLogging(void)675*35238bceSAndroid Build Coastguard Worker bool TestLog::isSupressLogging(void)
676*35238bceSAndroid Build Coastguard Worker {
677*35238bceSAndroid Build Coastguard Worker return m_logSupressed;
678*35238bceSAndroid Build Coastguard Worker }
679*35238bceSAndroid Build Coastguard Worker
680*35238bceSAndroid Build Coastguard Worker const TestLog::BeginMessageToken TestLog::Message = TestLog::BeginMessageToken();
681*35238bceSAndroid Build Coastguard Worker const TestLog::EndMessageToken TestLog::EndMessage = TestLog::EndMessageToken();
682*35238bceSAndroid Build Coastguard Worker const TestLog::EndImageSetToken TestLog::EndImageSet = TestLog::EndImageSetToken();
683*35238bceSAndroid Build Coastguard Worker const TestLog::EndSectionToken TestLog::EndSection = TestLog::EndSectionToken();
684*35238bceSAndroid Build Coastguard Worker const TestLog::EndShaderProgramToken TestLog::EndShaderProgram = TestLog::EndShaderProgramToken();
685*35238bceSAndroid Build Coastguard Worker const TestLog::SampleInfoToken TestLog::SampleInfo = TestLog::SampleInfoToken();
686*35238bceSAndroid Build Coastguard Worker const TestLog::EndSampleInfoToken TestLog::EndSampleInfo = TestLog::EndSampleInfoToken();
687*35238bceSAndroid Build Coastguard Worker const TestLog::BeginSampleToken TestLog::Sample = TestLog::BeginSampleToken();
688*35238bceSAndroid Build Coastguard Worker const TestLog::EndSampleToken TestLog::EndSample = TestLog::EndSampleToken();
689*35238bceSAndroid Build Coastguard Worker const TestLog::EndSampleListToken TestLog::EndSampleList = TestLog::EndSampleListToken();
690*35238bceSAndroid Build Coastguard Worker
691*35238bceSAndroid Build Coastguard Worker } // namespace tcu
692