Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NEYRET Fabrice
Ork
Commits
c8135687
Commit
c8135687
authored
Dec 19, 2021
by
Eric Bruneton
Browse files
Fix issues due to more strict validations in the OpenGL driver.
parent
d070f551
Changes
6
Hide whitespace changes
Inline
Side-by-side
ork/render/Mesh.h
View file @
c8135687
...
...
@@ -556,7 +556,6 @@ void Mesh<vertex, index>::clear()
if
(
created
)
{
buffers
->
reset
();
buffers
->
setIndicesBuffer
(
NULL
);
created
=
false
;
}
}
...
...
@@ -565,22 +564,16 @@ void Mesh<vertex, index>::clearBuffers()
{
if
(
created
)
{
buffers
->
reset
();
created
=
false
;
}
}
template
<
class
vertex
,
class
index
>
void
Mesh
<
vertex
,
index
>::
createBuffers
()
const
{
if
(
usage
==
GPU_STATIC
||
usage
==
GPU_DYNAMIC
||
usage
==
GPU_STREAM
)
{
GPUBuffer
*
gpub
=
new
GPUBuffer
();
vertexBuffer
=
ptr
<
Buffer
>
(
gpub
);
if
(
usage
==
GPU_STATIC
)
{
uploadVertexDataToGPU
(
STATIC_DRAW
);
}
}
else
if
(
usage
==
CPU
)
{
CPUBuffer
*
cpub
=
new
CPUBuffer
(
vertices
);
vertexBuffer
=
ptr
<
Buffer
>
((
Buffer
*
)
cpub
);
GPUBuffer
*
gpub
=
new
GPUBuffer
();
vertexBuffer
=
ptr
<
Buffer
>
(
gpub
);
if
(
usage
==
GPU_STATIC
)
{
uploadVertexDataToGPU
(
STATIC_DRAW
);
}
assert
(
buffers
->
getAttributeCount
()
>
0
);
...
...
@@ -589,15 +582,10 @@ void Mesh<vertex, index>::createBuffers() const
}
if
(
indicesCount
!=
0
)
{
if
(
usage
==
GPU_STATIC
||
usage
==
GPU_DYNAMIC
||
usage
==
GPU_STREAM
)
{
GPUBuffer
*
gpub
=
new
GPUBuffer
();
indexBuffer
=
ptr
<
Buffer
>
(
gpub
);
if
(
usage
==
GPU_STATIC
)
{
uploadIndexDataToGPU
(
STATIC_DRAW
);
}
}
else
if
(
usage
==
CPU
)
{
CPUBuffer
*
cpub
=
new
CPUBuffer
(
indices
);
indexBuffer
=
ptr
<
Buffer
>
(
cpub
);
GPUBuffer
*
gpub
=
new
GPUBuffer
();
indexBuffer
=
ptr
<
Buffer
>
(
gpub
);
if
(
usage
==
GPU_STATIC
)
{
uploadIndexDataToGPU
(
STATIC_DRAW
);
}
AttributeType
type
;
...
...
ork/render/MeshBuffers.cpp
View file @
c8135687
...
...
@@ -58,8 +58,9 @@ GLenum getAttributeType(AttributeType t);
GLenum
getMeshMode
(
MeshMode
m
);
MeshBuffers
::
MeshBuffers
()
:
Object
(
"MeshBuffers"
),
mode
(
POINTS
),
nvertices
(
0
),
nindices
(
0
),
primitiveRestart
(
-
1
),
patchVertices
(
0
)
Object
(
"MeshBuffers"
),
mode
(
POINTS
),
nvertices
(
0
),
nindices
(
0
),
primitiveRestart
(
-
1
),
patchVertices
(
0
)
,
dirty
(
true
)
{
glGenVertexArrays
(
1
,
&
vertexArrayObject
);
}
MeshBuffers
::~
MeshBuffers
()
...
...
@@ -89,6 +90,7 @@ void MeshBuffers::addAttributeBuffer(int index, int size, AttributeType type, bo
{
ptr
<
AttributeBuffer
>
a
=
new
AttributeBuffer
(
index
,
size
,
type
,
norm
,
NULL
);
attributeBuffers
.
push_back
(
a
);
dirty
=
true
;
}
void
MeshBuffers
::
addAttributeBuffer
(
int
index
,
int
size
,
int
vertexsize
,
AttributeType
type
,
bool
norm
)
...
...
@@ -102,21 +104,30 @@ void MeshBuffers::addAttributeBuffer(int index, int size, int vertexsize, Attrib
}
ptr
<
AttributeBuffer
>
a
=
new
AttributeBuffer
(
index
,
size
,
type
,
norm
,
NULL
,
vertexsize
,
offset
);
attributeBuffers
.
push_back
(
a
);
dirty
=
true
;
}
void
MeshBuffers
::
addAttributeBuffer
(
ptr
<
AttributeBuffer
>
buffer
)
{
attributeBuffers
.
push_back
(
buffer
);
dirty
=
true
;
}
void
MeshBuffers
::
setIndicesBuffer
(
ptr
<
AttributeBuffer
>
indices
)
{
indicesBuffer
=
indices
;
dirty
=
true
;
}
void
MeshBuffers
::
bind
()
const
{
if
(
!
dirty
)
{
glBindVertexArray
(
vertexArrayObject
);
assert
(
FrameBuffer
::
getError
()
==
0
);
return
;
}
assert
(
attributeBuffers
.
size
()
>
0
);
glBindVertexArray
(
vertexArrayObject
);
// binds the attribute buffers for each attribute
for
(
int
i
=
(
int
)
attributeBuffers
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
ptr
<
AttributeBuffer
>
a
=
attributeBuffers
[
i
];
...
...
@@ -142,15 +153,12 @@ void MeshBuffers::bind() const
offset
=
b
->
data
(
indicesBuffer
->
offset
);
}
assert
(
FrameBuffer
::
getError
()
==
0
);
dirty
=
false
;
}
void
MeshBuffers
::
unbind
()
const
{
for
(
int
i
=
(
int
)
attributeBuffers
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
ptr
<
AttributeBuffer
>
a
=
attributeBuffers
[
i
];
int
index
=
a
->
index
;
glDisableVertexAttribArray
(
index
);
}
glBindVertexArray
(
0
);
assert
(
glGetError
()
==
0
);
}
...
...
ork/render/MeshBuffers.h
View file @
c8135687
...
...
@@ -378,6 +378,16 @@ private:
*/
ptr
<
AttributeBuffer
>
indicesBuffer
;
/**
* The Vertex Array Object (VAO) of this mesh.
*/
GLuint
vertexArrayObject
;
/**
* Whether the Vertex Array Object (VAO) of this mesh must be updated.
*/
mutable
bool
dirty
;
/**
* The currently bound mesh buffers. The buffers of a mesh must be bound
* before it can be drawn.
...
...
ork/render/Types.h
View file @
c8135687
...
...
@@ -240,7 +240,6 @@ enum MeshMode {
*/
enum
MeshUsage
{
CPU
,
///<
GPU_STATIC
,
///<
GPU_DYNAMIC
,
///<
GPU_STREAM
///<
...
...
ork/scenegraph/ShowInfoTask.cpp
View file @
c8135687
...
...
@@ -128,7 +128,7 @@ void ShowInfoTask::init(ptr<Font> f, ptr<Program> p, int color, float size, vec3
position
=
pos
;
fontHeight
=
size
;
if
(
fontMesh
==
NULL
)
{
fontMesh
=
new
Mesh
<
Font
::
Vertex
,
unsigned
int
>
(
TRIANGLES
,
C
PU
);
fontMesh
=
new
Mesh
<
Font
::
Vertex
,
unsigned
int
>
(
TRIANGLES
,
G
PU
_STREAM
);
fontMesh
->
addAttributeType
(
0
,
4
,
A16F
,
false
);
fontMesh
->
addAttributeType
(
1
,
4
,
A8UI
,
true
);
}
...
...
test/TestFrameBuffer.cpp
View file @
c8135687
...
...
@@ -782,8 +782,10 @@ TEST4(drawIndirectInstancingDirect)
quad
->
addVertex
(
vec4f
(
1
,
1
,
0
,
1
));
ptr
<
MeshBuffers
>
m
=
quad
->
getBuffers
();
fb
->
clear
(
true
,
true
,
true
);
int
buf
[
4
]
=
{
3
,
8
,
0
,
0
};
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
CPUBuffer
(
buf
));
int
bufData
[
4
]
=
{
3
,
8
,
0
,
0
};
ptr
<
GPUBuffer
>
buf
=
new
GPUBuffer
();
buf
->
setData
(
4
*
sizeof
(
int
),
bufData
,
STATIC_DRAW
);
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
*
buf
);
int
tPixels
[
4
*
8
*
8
*
8
];
int
fbPixels
[
4
*
8
*
8
];
int
l
=
4
*
8
*
8
*
3
;
...
...
@@ -817,8 +819,10 @@ TEST4(drawIndirectInstancingIndices)
quad
->
addIndice
(
3
);
ptr
<
MeshBuffers
>
m
=
quad
->
getBuffers
();
fb
->
clear
(
true
,
true
,
true
);
int
buf
[
5
]
=
{
3
,
8
,
3
,
0
,
0
};
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
CPUBuffer
(
buf
));
int
bufData
[
5
]
=
{
3
,
8
,
3
,
0
,
0
};
ptr
<
GPUBuffer
>
buf
=
new
GPUBuffer
();
buf
->
setData
(
5
*
sizeof
(
int
),
bufData
,
STATIC_DRAW
);
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
*
buf
);
int
tPixels
[
4
*
8
*
8
*
8
];
int
fbPixels
[
4
*
8
*
8
];
int
l
=
4
*
8
*
8
*
3
;
...
...
@@ -852,8 +856,10 @@ TEST4(drawIndirectInstancingIndicesWithBase)
quad
->
addIndice
(
3
);
ptr
<
MeshBuffers
>
m
=
quad
->
getBuffers
();
fb
->
clear
(
true
,
true
,
true
);
int
buf
[
5
]
=
{
3
,
8
,
0
,
1
,
0
};
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
CPUBuffer
(
buf
));
int
bufData
[
5
]
=
{
3
,
8
,
0
,
1
,
0
};
ptr
<
GPUBuffer
>
buf
=
new
GPUBuffer
();
buf
->
setData
(
5
*
sizeof
(
int
),
bufData
,
STATIC_DRAW
);
fb
->
drawIndirect
(
p
,
*
m
,
TRIANGLES
,
*
buf
);
int
tPixels
[
4
*
8
*
8
*
8
];
int
fbPixels
[
4
*
8
*
8
];
int
l
=
4
*
8
*
8
*
3
;
...
...
@@ -910,7 +916,7 @@ TEST(cpuMeshModificationDirect)
Texture
::
Parameters
().
mag
(
NEAREST
),
Buffer
::
Parameters
(),
CPUBuffer
(
NULL
)),
0
);
fb
->
setViewport
(
vec4
<
GLint
>
(
0
,
0
,
8
,
8
));
ptr
<
Program
>
p
=
new
Program
(
new
Module
(
330
,
FRAGMENT_SHADER
));
ptr
<
Mesh
<
vec4f
,
unsigned
int
>
>
quad
=
new
Mesh
<
vec4f
,
unsigned
int
>
(
TRIANGLE_STRIP
,
C
PU
);
ptr
<
Mesh
<
vec4f
,
unsigned
int
>
>
quad
=
new
Mesh
<
vec4f
,
unsigned
int
>
(
TRIANGLE_STRIP
,
G
PU
_DYNAMIC
);
quad
->
addAttributeType
(
0
,
4
,
A32F
,
false
);
quad
->
addVertex
(
vec4f
(
-
1
,
-
1
,
0
,
1
));
quad
->
addVertex
(
vec4f
(
1
,
-
1
,
0
,
1
));
...
...
@@ -940,7 +946,7 @@ TEST(cpuMeshModificationIndices)
Texture
::
Parameters
().
mag
(
NEAREST
),
Buffer
::
Parameters
(),
CPUBuffer
(
NULL
)),
0
);
fb
->
setViewport
(
vec4
<
GLint
>
(
0
,
0
,
8
,
8
));
ptr
<
Program
>
p
=
new
Program
(
new
Module
(
330
,
FRAGMENT_SHADER
));
ptr
<
Mesh
<
vec4f
,
unsigned
int
>
>
quad
=
new
Mesh
<
vec4f
,
unsigned
int
>
(
TRIANGLE_STRIP
,
C
PU
);
ptr
<
Mesh
<
vec4f
,
unsigned
int
>
>
quad
=
new
Mesh
<
vec4f
,
unsigned
int
>
(
TRIANGLE_STRIP
,
G
PU
_DYNAMIC
);
quad
->
addAttributeType
(
0
,
4
,
A32F
,
false
);
quad
->
addVertex
(
vec4f
(
-
1
,
-
1
,
0
,
1
));
quad
->
addVertex
(
vec4f
(
1
,
-
1
,
0
,
1
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment