Skip to content

Commit

Permalink
Fixing formatting issues in code.
Browse files Browse the repository at this point in the history
  • Loading branch information
oneLOH committed Oct 17, 2023
1 parent 09618d8 commit 3f5169d
Show file tree
Hide file tree
Showing 31 changed files with 12,952 additions and 13,073 deletions.
366 changes: 176 additions & 190 deletions 3rdparty/SiftGPU/CuTexImage.cpp

Large diffs are not rendered by default.

84 changes: 43 additions & 41 deletions 3rdparty/SiftGPU/CuTexImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//
// Permission to use, copy, modify and distribute this software and its
// documentation for educational, research and non-profit purposes, without
// fee, and without a written agreement is hereby granted, provided that the
// above copyright notice and the following paragraph appear in all copies.
// fee, and without a written agreement is hereby granted, provided that
// the above copyright notice and the following paragraph appear in all copies.
//
// The University of North Carolina at Chapel Hill make no representations
// about the suitability of this software for any purpose. It is provided
Expand All @@ -20,57 +20,59 @@
//
////////////////////////////////////////////////////////////////////////////


#ifndef CU_TEX_IMAGE_H
#define CU_TEX_IMAGE_H

class GLTexImage;
struct cudaArray;
struct textureReference;

//using texture2D from linear memory
// using texture2D from linear memory

#define SIFTGPU_ENABLE_LINEAR_TEX2D

class CuTexImage
{
protected:
void* _cuData;
cudaArray* _cuData2D;
int _numChannel;
size_t _numBytes;
int _imgWidth;
int _imgHeight;
int _texWidth;
int _texHeight;
GLuint _fromPBO;
public:
virtual void SetImageSize(int width, int height);
virtual bool InitTexture(int width, int height, int nchannel = 1);
void InitTexture2D();
inline void BindTexture(textureReference& texRef);
inline void BindTexture2D(textureReference& texRef);
void CopyToTexture2D();
void CopyToHost(void* buf);
void CopyToHost(void* buf, int stream);
void CopyFromHost(const void* buf);
int CopyToPBO(GLuint pbo);
void CopyFromPBO(int width, int height, GLuint pbo);
static int DebugCopyToTexture2D();
public:
inline int GetImgWidth(){return _imgWidth;}
inline int GetImgHeight(){return _imgHeight;}
inline int GetDataSize(){return _numBytes;}
public:
CuTexImage();
CuTexImage(int width, int height, int nchannel, GLuint pbo);
virtual ~CuTexImage();
friend class ProgramCU;
friend class PyramidCU;
typedef unsigned int GLuint;

class CuTexImage {
protected:
void *_cuData;
cudaArray *_cuData2D;
int _numChannel;
size_t _numBytes;
int _imgWidth;
int _imgHeight;
int _texWidth;
int _texHeight;
GLuint _fromPBO;

public:
virtual void SetImageSize(int width, int height);
virtual bool InitTexture(int width, int height, int nchannel = 1);
void InitTexture2D();
inline void BindTexture(textureReference &texRef);
inline void BindTexture2D(textureReference &texRef);
void CopyToTexture2D();
void CopyToHost(void *buf);
void CopyToHost(void *buf, int stream);
void CopyFromHost(const void *buf);
int CopyToPBO(GLuint pbo);
void CopyFromPBO(int width, int height, GLuint pbo);
static int DebugCopyToTexture2D();

public:
inline int GetImgWidth() { return _imgWidth; }
inline int GetImgHeight() { return _imgHeight; }
inline int GetDataSize() { return _numBytes; }

public:
CuTexImage();
CuTexImage(int width, int height, int nchannel, GLuint pbo);
virtual ~CuTexImage();
friend class ProgramCU;
friend class PyramidCU;
};

//////////////////////////////////////////////////
//transfer OpenGL Texture to PBO, then to CUDA vector
// transfer OpenGL Texture to PBO, then to CUDA vector
//#endif
#endif // !defined(CU_TEX_IMAGE_H)

103 changes: 47 additions & 56 deletions 3rdparty/SiftGPU/FrameBufferObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,87 @@
//
// Permission to use, copy, modify and distribute this software and its
// documentation for educational, research and non-profit purposes, without
// fee, and without a written agreement is hereby granted, provided that the
// above copyright notice and the following paragraph appear in all copies.
//
// fee, and without a written agreement is hereby granted, provided that
// the above copyright notice and the following paragraph appear in all copies.
//
// The University of North Carolina at Chapel Hill make no representations
// about the suitability of this software for any purpose. It is provided
// 'as is' without express or implied warranty.
// 'as is' without express or implied warranty.
//
// Please send BUG REPORTS to ccwu@cs.unc.edu
//
////////////////////////////////////////////////////////////////////////////


#include "GL/glew.h"
#include <stdlib.h>
#include "GlobalUtil.h"
#include "FrameBufferObject.h"

//whether use only one FBO globally
int FrameBufferObject::UseSingleFBO=1;
GLuint FrameBufferObject::GlobalFBO=0;
// whether use only one FBO globally
int FrameBufferObject::UseSingleFBO = 1;
GLuint FrameBufferObject::GlobalFBO = 0;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

FrameBufferObject::FrameBufferObject(int autobind)
{
if(UseSingleFBO && GlobalFBO)
{
_fboID = GlobalFBO;
}else
{
glGenFramebuffersEXT(1, &_fboID);
if(UseSingleFBO )GlobalFBO = _fboID;
}
if(autobind ) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
FrameBufferObject::FrameBufferObject(int autobind) {
if (UseSingleFBO && GlobalFBO) {
_fboID = GlobalFBO;
} else {
glGenFramebuffersEXT(1, &_fboID);
if (UseSingleFBO)
GlobalFBO = _fboID;
}
if (autobind)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
}

FrameBufferObject::~FrameBufferObject()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
if(!UseSingleFBO )
{
glDeleteFramebuffersEXT (1,&_fboID);
}
FrameBufferObject::~FrameBufferObject() {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
if (!UseSingleFBO) {
glDeleteFramebuffersEXT(1, &_fboID);
}
}

void FrameBufferObject::DeleteGlobalFBO()
{
if(UseSingleFBO)
{
glDeleteFramebuffersEXT (1,&GlobalFBO);
GlobalFBO = 0;
}
void FrameBufferObject::DeleteGlobalFBO() {
if (UseSingleFBO) {
glDeleteFramebuffersEXT(1, &GlobalFBO);
GlobalFBO = 0;
}
}

void FrameBufferObject::AttachDepthTexture(GLenum textureTarget, GLuint texID)
{
void FrameBufferObject::AttachDepthTexture(GLenum textureTarget, GLuint texID) {

glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textureTarget, texID, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
textureTarget, texID, 0);
}

void FrameBufferObject::AttachTexture(GLenum textureTarget, GLenum attachment, GLuint texId)
{
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, textureTarget, texId, 0);
void FrameBufferObject::AttachTexture(GLenum textureTarget, GLenum attachment,
GLuint texId) {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, textureTarget,
texId, 0);
}

void FrameBufferObject::BindFBO()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
void FrameBufferObject::BindFBO() {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
}

void FrameBufferObject::UnbindFBO()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
void FrameBufferObject::UnbindFBO() {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

void FrameBufferObject::UnattachTex(GLenum attachment)
{
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0 );
void FrameBufferObject::UnattachTex(GLenum attachment) {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0,
0);
}

void FrameBufferObject::AttachRenderBuffer(GLenum attachment, GLuint buffID)
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, buffID);

void FrameBufferObject::AttachRenderBuffer(GLenum attachment, GLuint buffID) {
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_RENDERBUFFER_EXT, buffID);
}

void FrameBufferObject:: UnattachRenderBuffer(GLenum attachment)
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, 0);
void FrameBufferObject::UnattachRenderBuffer(GLenum attachment) {
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_RENDERBUFFER_EXT, 0);
}

49 changes: 25 additions & 24 deletions 3rdparty/SiftGPU/FrameBufferObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,41 @@
//
// Permission to use, copy, modify and distribute this software and its
// documentation for educational, research and non-profit purposes, without
// fee, and without a written agreement is hereby granted, provided that the
// above copyright notice and the following paragraph appear in all copies.
//
// fee, and without a written agreement is hereby granted, provided that
// the above copyright notice and the following paragraph appear in all copies.
//
// The University of North Carolina at Chapel Hill make no representations
// about the suitability of this software for any purpose. It is provided
// 'as is' without express or implied warranty.
// 'as is' without express or implied warranty.
//
// Please send BUG REPORTS to ccwu@cs.unc.edu
//
////////////////////////////////////////////////////////////////////////////


#if !defined(_FRAME_BUFFER_OBJECT_H)
#define _FRAME_BUFFER_OBJECT_H

class FrameBufferObject
{
static GLuint GlobalFBO; //not thread-safe
GLuint _fboID;
public:
static int UseSingleFBO;
public:
static void DeleteGlobalFBO();
static void UnattachTex(GLenum attachment);
static void UnbindFBO();
static void AttachDepthTexture(GLenum textureTarget, GLuint texID);
static void AttachTexture( GLenum textureTarget, GLenum attachment, GLuint texID);
static void AttachRenderBuffer(GLenum attachment, GLuint buffID );
static void UnattachRenderBuffer(GLenum attachment);
public:
void BindFBO();
FrameBufferObject(int autobind = 1);
~FrameBufferObject();
class FrameBufferObject {
static GLuint GlobalFBO; // not thread-safe
GLuint _fboID;

public:
static int UseSingleFBO;

public:
static void DeleteGlobalFBO();
static void UnattachTex(GLenum attachment);
static void UnbindFBO();
static void AttachDepthTexture(GLenum textureTarget, GLuint texID);
static void AttachTexture(GLenum textureTarget, GLenum attachment,
GLuint texID);
static void AttachRenderBuffer(GLenum attachment, GLuint buffID);
static void UnattachRenderBuffer(GLenum attachment);

public:
void BindFBO();
FrameBufferObject(int autobind = 1);
~FrameBufferObject();
};

#endif
#endif
Loading

0 comments on commit 3f5169d

Please sign in to comment.