Fixed mac compatability

This commit is contained in:
2017-03-07 10:24:55 -08:00
6 changed files with 123 additions and 27 deletions

View File

@@ -99,10 +99,9 @@ void Hardware_Caster::validate()
void Hardware_Caster::create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim) {
create_image_buffer("texture_atlas", t->getSize().y * t->getSize().x * 4 * sizeof(float), t);
create_image_buffer("texture_atlas", t->getSize().x * t->getSize().x * 4 * sizeof(float), t, CL_MEM_READ_ONLY);
// create_buffer observes arg 3's
sf::Vector2u v = t->getSize();
create_buffer("atlas_dim", sizeof(sf::Vector2u) , &v);
@@ -191,7 +190,7 @@ void Hardware_Caster::create_viewport(int width, int height, float v_fov, float
viewport_sprite.setTexture(viewport_texture);
// Pass the buffer to opencl
create_image_buffer("image", sizeof(sf::Uint8) * width * height * 4, &viewport_texture);
create_image_buffer("image", sizeof(sf::Uint8) * width * height * 4, &viewport_texture, CL_MEM_WRITE_ONLY);
}
@@ -533,7 +532,7 @@ int Hardware_Caster::set_kernel_arg(
}
int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture) {
int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture, cl_int access_type) {
// I can imagine overwriting buffers will be common, so I think
// this is safe to overwrite / release old buffers quietly
@@ -543,7 +542,7 @@ int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size,
int error;
cl_mem buff = clCreateFromGLTexture(
getContext(), CL_MEM_WRITE_ONLY, GL_TEXTURE_2D,
getContext(), access_type, GL_TEXTURE_2D,
0, texture->getNativeHandle(), &error);
if (assert(error, "clCreateFromGLTexture"))