author | jdv |
Tue, 05 Mar 2019 16:36:45 +0530 | |
branch | metal-prototype-branch |
changeset 57243 | 8c3a74033daf |
parent 57196 | a95707a39ff5 |
permissions | -rw-r--r-- |
57196
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
1 |
/* |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved. |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
4 |
* |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
10 |
* |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
15 |
* accompanied this code). |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
16 |
* |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
20 |
* |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
23 |
* questions. |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
24 |
*/ |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
25 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
26 |
#ifndef VertexDataManager_h_Included |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
27 |
#define VertexDataManager_h_Included |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
28 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
29 |
#import <Metal/Metal.h> |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
30 |
#import "shaders/MetalShaderTypes.h" |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
31 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
32 |
// --------------------------------------------------------------------- |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
33 |
//TODO : This implementation should be redesigned as a singleton class |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
34 |
//TODO : Drawing optimization can be done - if current primitive-type to be |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
35 |
// drawn is equal to previous primitive-type in the list/array |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
36 |
// (Similar to previous-op in OGL) |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
37 |
// --------------------------------------------------------------------- |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
38 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
39 |
typedef struct |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
40 |
{ |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
41 |
MTLPrimitiveType type; |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
42 |
unsigned int offset_in_index_buffer; |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
43 |
unsigned int no_of_indices; |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
44 |
unsigned int primitiveInstances; |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
45 |
} MetalPrimitiveData; |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
46 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
47 |
void VertexDataManager_init(id<MTLDevice> device); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
48 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
49 |
void VertexDataManager_addLineVertexData(MetalVertex v1, MetalVertex v2); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
50 |
void VertexDataManager_addQuadVertexData(MetalVertex v1, MetalVertex v2, MetalVertex v3, MetalVertex v4); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
51 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
52 |
id<MTLBuffer> VertexDataManager_getVertexBuffer(); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
53 |
id<MTLBuffer> VertexDataManager_getIndexBuffer(); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
54 |
MetalPrimitiveData** VertexDataManager_getAllPrimitives(); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
55 |
unsigned int VertexDataManager_getNoOfPrimitives(); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
56 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
57 |
void VertexDataManager_freeAllPrimitives(); |
57243
8c3a74033daf
Enable resize operation for drawing primitives by adding high level blit loops logic
jdv
parents:
57196
diff
changeset
|
58 |
void VertexDataManager_reset(id<MTLDevice> device); |
57196
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
59 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
60 |
// should be private |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
61 |
void addVertex(MetalVertex vert); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
62 |
void addIndex(unsigned short vertexNum); |
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
63 |
|
a95707a39ff5
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff
changeset
|
64 |
#endif //VertexDataManager_h_Included |