改进光栅化测试流程
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
#include <pipe/dvc_rasterizer.h>
|
#include "pipe/dvc_rasterizer.h"
|
||||||
#include <buffer/dvu_dump_buffer.h>
|
#include "buffer/dvu_dump_buffer.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@@ -224,19 +223,19 @@ public:
|
|||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
bool succ = true;
|
bool succ = true;
|
||||||
uint32_t* colBuf = new uint32_t[m_width*m_height];
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < m_width*m_height; i++) {
|
for (int32_t i = 0; i < m_width*m_height; i++) {
|
||||||
colBuf[i] = m_pixelBuf[i].load();
|
|
||||||
if (m_pixelBuf[i] == 0) {
|
if (m_pixelBuf[i] == 0) {
|
||||||
if (debug) printf("error: %d,%d=%d\n", i%m_width, i/ m_width, m_pixelBuf[(size_t)i].load());
|
if (debug) printf("error: %d,%d=%d\n", i%m_width, i/ m_width, m_pixelBuf[(size_t)i].load());
|
||||||
succ = false;
|
succ = false;
|
||||||
//return false;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
davinci_utils::dump_pixel_buffer("debug.png", m_width, m_height, colBuf, PF_UINT8_RGBA);
|
if (!succ) {
|
||||||
delete[] colBuf;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return succ;
|
return succ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -262,6 +261,27 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dumpToPNG(const char* szFileName, bool binary)
|
||||||
|
{
|
||||||
|
uint32_t* pixelBuffer = new uint32_t[m_width * m_height];
|
||||||
|
for (int32_t i = 0; i < m_width * m_height; i++)
|
||||||
|
{
|
||||||
|
if (binary) {
|
||||||
|
pixelBuffer[i] = m_pixelBuf[i].load() != 0 ? 0xFF000000 : 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pixelBuffer[i] = m_pixelBuf[i].load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!davinci_utils::dump_pixel_buffer(szFileName, m_width, m_height, pixelBuffer, PF_UINT8_RGBA))
|
||||||
|
{
|
||||||
|
delete[] pixelBuffer;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
delete[] pixelBuffer;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
int32_t m_width, m_height;
|
int32_t m_width, m_height;
|
||||||
std::atomic<uint32_t>* m_pixelBuf;
|
std::atomic<uint32_t>* m_pixelBuf;
|
||||||
@@ -271,7 +291,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
static bool _triangleRasterizationRules(Canvas& canvas, const Triangle& triangle, const PixelBuf& pixelExpect, bool ccw=true)
|
static bool _triangleRasterizationRules(Canvas& canvas, const Triangle& triangle, const PixelBuf& pixelExpect, bool ccw=true, const char* dumpPNGName=nullptr)
|
||||||
{
|
{
|
||||||
auto razFunc = std::bind(&Canvas::razFunction_fetchadd, &canvas, std::placeholders::_1, std::placeholders::_2);
|
auto razFunc = std::bind(&Canvas::razFunction_fetchadd, &canvas, std::placeholders::_1, std::placeholders::_2);
|
||||||
|
|
||||||
@@ -281,6 +301,11 @@ static bool _triangleRasterizationRules(Canvas& canvas, const Triangle& triangle
|
|||||||
triangle.p1, triangle.p2, triangle.p3,
|
triangle.p1, triangle.p2, triangle.p3,
|
||||||
razFunc, ccw);
|
razFunc, ccw);
|
||||||
|
|
||||||
|
if (dumpPNGName != nullptr)
|
||||||
|
{
|
||||||
|
canvas.dumpToPNG(dumpPNGName, true);
|
||||||
|
}
|
||||||
|
|
||||||
return canvas.checkResult(pixelExpect);
|
return canvas.checkResult(pixelExpect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,9 +401,6 @@ TEST(Rasterizer, Basic)
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
TEST(Rasterizer, Delaunay)
|
TEST(Rasterizer, Delaunay)
|
||||||
{
|
{
|
||||||
//seed=1499743811, counts=5, range=0.8f;
|
|
||||||
//seed=1499670829, counts=5, range=1.f;
|
|
||||||
|
|
||||||
const int32_t width = 1024, height = 1024;
|
const int32_t width = 1024, height = 1024;
|
||||||
const int32_t verticesCounts = MathUtil::rangeRandom(5, 30);
|
const int32_t verticesCounts = MathUtil::rangeRandom(5, 30);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user