Git Product home page Git Product logo

Comments (1)

KosLooney avatar KosLooney commented on June 30, 2024

It happens here too (amd + windows).

It looks like you have to put these uniform constants in the for loop to make it work as intended:

kinc_g4_set_matrix4(mvp_loc, &mvp_mat);
kinc_g4_set_matrix4(v_loc, &v_mat);
kinc_g4_set_floats(lightPos_loc, (float*)&light_pos, 3);

The constants are written to a vertexConstantBuffer and fragmentConstantBuffer.

static kinc_g5_constant_buffer_t vertexConstantBuffer;
static kinc_g5_constant_buffer_t fragmentConstantBuffer;

Each call to kinc_g4_draw_indexed_vertices on G4onG5 uses a offset (constantBufferIndex*constantBufferSize) from these buffers and they are then linked with a g5 command.

kinc_g5_constant_buffer_lock(&vertexConstantBuffer, 0, constantBufferSize);
kinc_g5_constant_buffer_lock(&fragmentConstantBuffer, 0, constantBufferSize);
memcpy(vertexConstantBuffer.data, current_state.vertex_constant_data, constantBufferSize);
memcpy(fragmentConstantBuffer.data, current_state.fragment_constant_data, constantBufferSize);
}
else {
kinc_g5_constant_buffer_lock(&vertexConstantBuffer, constantBufferIndex * constantBufferSize, constantBufferSize);
kinc_g5_constant_buffer_lock(&fragmentConstantBuffer, constantBufferIndex * constantBufferSize, constantBufferSize);

kinc_g5_command_list_set_vertex_constant_buffer(&commandList, &vertexConstantBuffer, constantBufferIndex * constantBufferSize, constantBufferSize);
kinc_g5_command_list_set_fragment_constant_buffer(&commandList, &fragmentConstantBuffer, constantBufferIndex * constantBufferSize, constantBufferSize);

void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) {
lastFragmentConstantBufferOffset = offset;
VkDescriptorSet descriptor_set = getDescriptorSet();
uint32_t offsets[2] = {lastVertexConstantBufferOffset, lastFragmentConstantBufferOffset};
vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, currentPipeline->impl.pipeline_layout, 0, 1, &descriptor_set, 2, offsets);
}

The command list is then executed every 100 draw calls, on a vertex_buffer change, kinc_g4_start() or on kinc_g4_end().

if (constantBufferIndex >= constantBufferMultiply || waitAfterNextDraw) {
kinc_g5_command_list_end(&commandList);
kinc_g5_command_list_execute(&commandList);
kinc_g5_command_list_wait_for_execution_to_finish(&commandList);
kinc_g5_command_list_begin(&commandList);
if (windows[current_window].current_render_targets[0] == NULL) {

So at the moment your 1st instance uses all constants and the rest are only using off_loc and rot_loc.
1st cube:
1st_call
2nd cube:
2nd_call

Edit:
The cubes eventually appear because each frame the mvp and v uniform constants are set on a different offset location
1st cube now has offset 344064:
1st_call_2

from kinc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.