Skip to content

Commit

Permalink
Fix compute for hxcpp
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jan 19, 2024
1 parent fedc52e commit 6a5fc9c
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 303 deletions.
176 changes: 0 additions & 176 deletions Backends/Kinc-hxcpp/kha/compute/Compute.hx

This file was deleted.

9 changes: 0 additions & 9 deletions Backends/Kinc-hxcpp/kha/compute/ConstantLocation.hx

This file was deleted.

45 changes: 0 additions & 45 deletions Backends/Kinc-hxcpp/kha/compute/Shader.hx

This file was deleted.

9 changes: 0 additions & 9 deletions Backends/Kinc-hxcpp/kha/compute/TextureUnit.hx

This file was deleted.

45 changes: 45 additions & 0 deletions Backends/Kinc-hxcpp/kha/graphics4/ComputeShader.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package kha.graphics4;

import haxe.io.Bytes;
import kha.Blob;

@:headerCode("
#include <kinc/graphics4/compute.h>
")
@:headerClassCode("kinc_g4_compute_shader shader;")
class ComputeShader {
public function new(sources: Array<Blob>, files: Array<String>) {
init(sources[0], files[0]);
}

function init(source: Blob, file: String): Void {
untyped __cpp__("kinc_g4_compute_shader_init(&shader, source->bytes->b->Pointer(), source->get_length());");
}

public function delete(): Void {
untyped __cpp__("kinc_g4_compute_shader_destroy(&shader);");
}

public function getConstantLocation(name: String): ConstantLocation {
var location = new kha.kore.graphics4.ConstantLocation();
initConstantLocation(location, name);
return location;
}

@:functionCode("location->location = kinc_g4_compute_shader_get_constant_location(&shader, name.c_str());")
function initConstantLocation(location: kha.kore.graphics4.ConstantLocation, name: String): Void {}

public function getTextureUnit(name: String): TextureUnit {
var unit = new kha.kore.graphics4.TextureUnit();
initTextureUnit(unit, name);
return unit;
}

@:functionCode("unit->unit = kinc_g4_compute_shader_get_texture_unit(&shader, name.c_str());")
function initTextureUnit(unit: kha.kore.graphics4.TextureUnit, name: String): Void {}

@:keep
function _forceInclude(): Void {
Bytes.alloc(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package kha.compute;

import kha.graphics4.VertexData;
package kha.graphics4;

@:headerCode("
#include <kinc/compute/compute.h>
#include <kinc/graphics4/compute.h>
")
@:headerClassCode("
#ifdef KORE_OPENGL
Expand Down
18 changes: 18 additions & 0 deletions Backends/Kinc-hxcpp/kha/kore/graphics4/Graphics.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import kha.graphics4.FragmentShader;
import kha.graphics4.BlendingFactor;
import kha.graphics4.BlendingOperation;
import kha.graphics4.CompareMode;
import kha.graphics4.ComputeShader;
import kha.graphics4.MipMapFilter;
import kha.graphics4.PipelineState;
import kha.graphics4.ShaderStorageBuffer;
import kha.graphics4.StencilAction;
import kha.graphics4.TexDir;
import kha.graphics4.TextureAddressing;
Expand Down Expand Up @@ -450,6 +452,22 @@ class Graphics implements kha.graphics4.Graphics {
}
}

public function setShaderStorageBuffer(buffer: ShaderStorageBuffer, index: Int) {
untyped __cpp__("
#ifdef KORE_OPENGL
kinc_compute_set_buffer(&buffer->buffer, index);
#endif
");
}

public function setComputeShader(shader: ComputeShader) {
untyped __cpp__("kinc_g4_set_compute_shader(&shader->shader);");
}

public function compute(x: Int, y: Int, z: Int) {
untyped __cpp__("kinc_g4_compute(x, y, z);");
}

@:functionCode("kinc_g4_restore_render_target();")
function renderToBackbuffer(): Void {}

Expand Down
7 changes: 0 additions & 7 deletions Sources/kha/compute/Access.hx

This file was deleted.

41 changes: 0 additions & 41 deletions Sources/kha/compute/Compute.hx

This file was deleted.

3 changes: 0 additions & 3 deletions Sources/kha/compute/ConstantLocation.hx

This file was deleted.

3 changes: 0 additions & 3 deletions Sources/kha/compute/TextureUnit.hx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kha.compute;
package kha.graphics4;

import kha.Blob;

Expand Down
Loading

0 comments on commit 6a5fc9c

Please sign in to comment.