Skip to content

Commit

Permalink
Merge branch 'vulkan' into msvc-vulkan
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Dec 14, 2024
2 parents eed710a + 9d8bf07 commit 152ca3b
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 201 deletions.
10 changes: 10 additions & 0 deletions beziercurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ struct BezierCurve
vk->lineData.extendMaterial(data);
}

void notRendered() {
vk->lineData.renderCount=0;
}

void queue(const triple *g, bool straight, double ratio) {
data.clear();
notRendered();
Onscreen=true;
init(pixelResolution*ratio);
render(g,straight);
Expand All @@ -59,8 +64,13 @@ struct Pixel
vk->pointData.extendPoint(data);
}

void notRendered() {
vk->pointData.renderCount=0;
}

void queue(const triple& p, double width) {
data.clear();
notRendered();
MaterialIndex=vk->materialIndex;
data.indices.push_back(data.addVertex(PointVertex{p,(float)width,MaterialIndex}));
append();
Expand Down
46 changes: 4 additions & 42 deletions bezierpatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -793,45 +793,6 @@ void BezierTriangle::render(const triple *p,

std::vector<float> zbuffer;

void transform(const std::vector<ColorVertex>& b)
{
unsigned n=b.size();
zbuffer.resize(n);

double Tz0=glm::value_ptr(vk->viewMat)[2];
double Tz1=glm::value_ptr(vk->viewMat)[6];
double Tz2=glm::value_ptr(vk->viewMat)[10];
for(unsigned i=0; i < n; ++i) {
const glm::vec3 v=b[i].position;
zbuffer[i]=Tz0*v.x+Tz1*v.y+Tz2*v.z;
}
}

// Sort nonintersecting triangles by depth.
int compare(const void *p, const void *P)
{
unsigned Ia=((uint32_t *) p)[0];
unsigned Ib=((uint32_t *) p)[1];
unsigned Ic=((uint32_t *) p)[2];

unsigned IA=((uint32_t *) P)[0];
unsigned IB=((uint32_t *) P)[1];
unsigned IC=((uint32_t *) P)[2];

return zbuffer[Ia]+zbuffer[Ib]+zbuffer[Ic] <
zbuffer[IA]+zbuffer[IB]+zbuffer[IC] ? -1 : 1;
}

// what is this for?
void sortTriangles()
{
if(!vk->transparentData.indices.empty()) {
transform(vk->transparentData.colorVertices);
qsort(&vk->transparentData.indices[0],vk->transparentData.indices.size()/3,
3*sizeof(uint32_t),compare);
}
}

void Triangles::queue(size_t nP, const triple* P, size_t nN, const triple* N,
size_t nC, const prc::RGBAColour* C, size_t nI,
const uint32_t (*PP)[3], const uint32_t (*NN)[3],
Expand All @@ -842,6 +803,7 @@ void Triangles::queue(size_t nP, const triple* P, size_t nN, const triple* N,
data.clear();
Onscreen=true;
transparent=Transparent;
notRendered();

data.colorVertices.resize(nP);

Expand Down Expand Up @@ -872,9 +834,9 @@ void Triangles::queue(size_t nP, const triple* P, size_t nN, const triple* N,
data.colorVertices[PI1]=ColorVertex{P1,N[NI[1]],MaterialIndex,glm::make_vec4(c1)};
data.colorVertices[PI2]=ColorVertex{P2,N[NI[2]],MaterialIndex,glm::make_vec4(c2)};
} else {
data.colorVertices[PI0]=ColorVertex{P0,N[NI[0]],MaterialIndex,glm::vec4(1.0f)};
data.colorVertices[PI1]=ColorVertex{P1,N[NI[1]],MaterialIndex,glm::vec4(1.0f)};
data.colorVertices[PI2]=ColorVertex{P2,N[NI[2]],MaterialIndex,glm::vec4(1.0f)};
data.colorVertices[PI0]=ColorVertex{P0,N[NI[0]],MaterialIndex};
data.colorVertices[PI1]=ColorVertex{P1,N[NI[1]],MaterialIndex};
data.colorVertices[PI2]=ColorVertex{P2,N[NI[2]],MaterialIndex};
}
triple Q[]={P0,P1,P2};
std::vector<GLuint> &q=data.indices;
Expand Down
2 changes: 0 additions & 2 deletions bezierpatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ struct Triangles : public BezierPatch {
}
};

extern void sortTriangles();

#endif

} //namespace camp
Expand Down
51 changes: 36 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -724,22 +724,43 @@ case "$OSTYPE" in
;;
*)
AC_CHECK_LIB([gccpp],[GC_throw_bad_alloc])
AC_CHECK_LIB([glut], [glutMainLoop],,
AC_MSG_NOTICE([*** Could not find libglut: will compile without OpenGL support ***]))
AC_CHECK_LIB([GL], [glDepthMask],
[AC_DEFINE(HAVE_LIBGL,1,
DEFINE_LIB([GL]))
LIBS=$LIBS"-lGL "
GLEW="glew.o "
INCL=$INCL" -Ibackports/glew/include "
AC_CHECK_LIB([GLX],[glXGetProcAddressARB],
GLEW=$GLEW"-lGLX ")],
AC_MSG_NOTICE([*** Could not find libGL: will compile without OpenGL support ***]))
AC_CHECK_LIB([glfw], [glfwShowWindow],
[
AC_CHECK_LIB([vulkan], [vkCreateInstance],
[
LIBS_SAVE=$LIBS
VULKAN_LIBS="-lMachineIndependent -lOSDependent -lGenericCodeGen "
LIBS=$LIBS"-lglfw -lvulkan "$VULKAN_LIBS"-lSPIRV "
AC_CHECK_LIB([glslang],[glslang_initialize_process],
[
AC_DEFINE(HAVE_LIBVULKAN,1,
DEFINE_LIB([vulkan]))
LIBS=$LIBS"-lglslang "
OPTIONS=$OPTIONS"-DYYDEBUG=0 "
],
[
LIBS=$LIBS"-lOGLCompiler "
AC_CHECK_LIB([glslang],[glslang_finalize_process],
[
AC_DEFINE(HAVE_LIBVULKAN,1,
DEFINE_LIB([vulkan]))
LIBS=$LIBS"-lglslang "
OPTIONS=$OPTIONS"-DYYDEBUG=0 "
],
[
AC_MSG_NOTICE([*** Could not find libglslang: will compile without Vulkan support ***])
LIBS=$LIBS_SAVE
]
)
]
)
],
AC_MSG_NOTICE([*** Could not find libvulkan: will compile without Vulkan support ***]))
],
AC_MSG_NOTICE([*** Could not find libglfw: will compile without Vulkan support ***]))
esac
if test "x$enable_offscreen" = "xyes"; then
AC_CHECK_LIB([OSMesa],OSMesaCreateContext,,
AC_MSG_NOTICE([*** Could not find libOSMesa: will compile without offscreen rendering support ***]))
fi
fi
fi
fi

Expand Down
20 changes: 0 additions & 20 deletions glew.c

This file was deleted.

Empty file removed glrender.cc
Empty file.
Empty file removed glrender.h
Empty file.
10 changes: 0 additions & 10 deletions memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@

#ifndef NOHASH

#ifdef HAVE_TR1_UNORDERED_MAP

#include <memory>
#include <tr1/unordered_map>
#define EXT std::tr1

#else

#ifdef HAVE_UNORDERED_MAP
#include <unordered_map>
#define EXT std
Expand All @@ -37,8 +29,6 @@

#endif

#endif

#ifdef __DECCXX_LIBCXX_RH70
#define CONST
#else
Expand Down
37 changes: 19 additions & 18 deletions picture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ void picture::render(double size2, const triple& Min, const triple& Max,
for(nodelist::const_iterator p=nodes.begin(); p != nodes.end(); ++p) {
assert(*p);
if(remesh) (*p)->meshinit();

(*p)->render(size2,Min,Max,perspective,remesh);
}
}
Expand Down Expand Up @@ -1593,8 +1594,8 @@ bool picture::shipout3(const string& prefix, const string& format,
if(Wait)
pthread_mutex_lock(&vk->readyLock);
#endif
} else {
#if !defined(_WIN32)
} else {
#if !defined(_WIN32)
int pid=fork();
if(pid == -1)
camp::reportError("Cannot fork process");
Expand All @@ -1606,19 +1607,19 @@ bool picture::shipout3(const string& prefix, const string& format,
#else
#pragma message("TODO: Check if (1) we need detach-based VK renderer")
#endif
}
#endif
}
}
#endif
}

#if HAVE_LIBGLM
vk->vkrender(prefix,pic,format,width,height,angle,
zoom,m,M,shift,margin,t,background,
nlights,lights,diffuse,specular,View,
oldpid);

if(format3d) {
string name=buildname(prefix,format);
abs3Doutfile *fileObj=nullptr;
if(format3d) {
string name=buildname(prefix,format);
abs3Doutfile *fileObj=nullptr;

if(webgl)
fileObj=new jsfile(name);
Expand All @@ -1634,18 +1635,18 @@ bool picture::shipout3(const string& prefix, const string& format,
}
#endif

if(fileObj) {
for (auto& p : pic->nodes) {
assert(p);
p->write(fileObj);
}
if(fileObj) {
for (auto& p : pic->nodes) {
assert(p);
p->write(fileObj);
}

fileObj->close();
delete fileObj;
}
fileObj->close();
delete fileObj;
}

if(webgl && View)
htmlView(name);
if(webgl && View)
htmlView(name);

return true;
}
Expand Down
Empty file removed shaders.cc
Empty file.
Loading

0 comments on commit 152ca3b

Please sign in to comment.