Browse Source

Add a number of missing funcs

jp9000 6 years ago
parent
commit
1581260320

+ 2 - 2
libobs-metal/metal-indexbuffer.mm

@@ -20,11 +20,11 @@ static inline size_t ConvertGSIndexTypeToSize(gs_index_type type)
 	throw "Failed to initialize index buffer";
 }
 
-void gs_index_buffer::PrepareBuffer()
+void gs_index_buffer::PrepareBuffer(void *new_indices)
 {
 	assert(isDynamic);
 	
-	indexBuffer = device->GetBuffer(indices.get(), len);
+	indexBuffer = device->GetBuffer(new_indices, len);
 #if _DEBUG
 	indexBuffer.label = @"index";
 #endif

+ 2 - 2
libobs-metal/metal-subsystem.hpp

@@ -227,7 +227,7 @@ struct gs_vertex_buffer : gs_obj {
 
 	inline id<MTLBuffer> PrepareBuffer(void *array, size_t elementSize,
 			NSString *name);
-	void PrepareBuffers();
+	void PrepareBuffers(const gs_vb_data *data);
 
 	void MakeBufferList(gs_vertex_shader *shader,
 			std::vector<id<MTLBuffer>> &buffers);
@@ -259,7 +259,7 @@ struct gs_index_buffer : gs_obj {
 
 	id<MTLBuffer>       indexBuffer;
 
-	void PrepareBuffer();
+	void PrepareBuffer(void *new_indices);
 	void InitBuffer();
 
 	inline void Release() {indexBuffer = nil;}

+ 36 - 4
libobs-metal/metal-subsystem.mm

@@ -1161,6 +1161,14 @@ void device_projection_pop(gs_device_t *device)
 	device->projStack.pop();
 }
 
+void device_debug_marker_begin(gs_device_t *, const char *, const float[4])
+{
+}
+
+void device_debug_marker_end(gs_device_t *)
+{
+}
+
 void gs_swapchain_destroy(gs_swapchain_t *swapchain)
 {
 	assert(swapchain->obj_type == gs_type::gs_swap_chain);
@@ -1385,7 +1393,8 @@ void gs_vertexbuffer_destroy(gs_vertbuffer_t *vertbuffer)
 	delete vertbuffer;
 }
 
-void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
+static inline void gs_vertexbuffer_flush_internal(gs_vertbuffer_t *vertbuffer,
+		const gs_vb_data *data)
 {
 	assert(vertbuffer->obj_type == gs_type::gs_vertex_buffer);
 
@@ -1395,7 +1404,18 @@ void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
 		return;
 	}
 
-	vertbuffer->PrepareBuffers();
+	vertbuffer->PrepareBuffers(data);
+}
+
+void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
+{
+	gs_vertexbuffer_flush_internal(vertbuffer, vertbuffer->vbData.get());
+}
+
+void gs_vertexbuffer_flush_direct(gs_vertbuffer_t *vertbuffer,
+		const gs_vb_data *data)
+{
+	gs_vertexbuffer_flush_internal(vertbuffer, data);
 }
 
 struct gs_vb_data *gs_vertexbuffer_get_data(const gs_vertbuffer_t *vertbuffer)
@@ -1413,7 +1433,8 @@ void gs_indexbuffer_destroy(gs_indexbuffer_t *indexbuffer)
 	delete indexbuffer;
 }
 
-void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
+static inline void gs_indexbuffer_flush_internal(gs_indexbuffer_t *indexbuffer,
+		void *indices)
 {
 	assert(indexbuffer->obj_type == gs_type::gs_index_buffer);
 
@@ -1423,7 +1444,18 @@ void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
 		return;
 	}
 
-	indexbuffer->PrepareBuffer();
+	indexbuffer->PrepareBuffer(indices);
+}
+
+void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
+{
+	gs_indexbuffer_flush_internal(indexbuffer, indexbuffer->indices.get());
+}
+
+void gs_indexbuffer_flush_direct(gs_indexbuffer_t *indexbuffer,
+		const void *data)
+{
+	gs_indexbuffer_flush_internal(indexbuffer, data);
 }
 
 void *gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer)

+ 10 - 10
libobs-metal/metal-vertexbuffer.mm

@@ -15,23 +15,23 @@ inline id<MTLBuffer> gs_vertex_buffer::PrepareBuffer(
 	return b;
 }
 
-void gs_vertex_buffer::PrepareBuffers()
+void gs_vertex_buffer::PrepareBuffers(const gs_vb_data *data)
 {
 	assert(isDynamic);
 
-	vertexBuffer = PrepareBuffer(vbData->points, sizeof(vec3), @"point");
-	if (vbData->normals)
-		normalBuffer = PrepareBuffer(vbData->normals, sizeof(vec3),
+	vertexBuffer = PrepareBuffer(data->points, sizeof(vec3), @"point");
+	if (data->normals)
+		normalBuffer = PrepareBuffer(data->normals, sizeof(vec3),
 				@"normal");
-	if (vbData->tangents)
-		tangentBuffer = PrepareBuffer(vbData->tangents, sizeof(vec3),
+	if (data->tangents)
+		tangentBuffer = PrepareBuffer(data->tangents, sizeof(vec3),
 				@"color");
-	if (vbData->colors)
-		colorBuffer = PrepareBuffer(vbData->colors, sizeof(uint32_t),
+	if (data->colors)
+		colorBuffer = PrepareBuffer(data->colors, sizeof(uint32_t),
 				@"tangent");
 
-	for (size_t i = 0; i < vbData->num_tex; i++) {
-		gs_tvertarray &tv = vbData->tvarray[i];
+	for (size_t i = 0; i < data->num_tex; i++) {
+		gs_tvertarray &tv = data->tvarray[i];
 		uvBuffers.push_back(PrepareBuffer(tv.array,
 				tv.width * sizeof(float), @"texcoord"));
 	}