Proper images selection, so animation images work now.

This commit is contained in:
Artem Kharytoniuk 2017-04-07 16:47:21 +03:00
parent 121afa2231
commit 6d50cb783c
4 changed files with 21 additions and 17 deletions

View File

@ -44,23 +44,26 @@ static float s_flipMatrix[16] = {
** GL_Bind
*/
void GL_Bind( image_t *image ) {
int texnum;
image_t* final_image = image;
if ( !image ) {
if (!final_image) {
ri.Printf( PRINT_WARNING, "GL_Bind: NULL image\n" );
texnum = tr.defaultImage->texnum;
} else {
texnum = image->texnum;
final_image = tr.defaultImage;
}
if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option
texnum = tr.dlightImage->texnum;
final_image = tr.dlightImage;
}
int texnum = final_image->texnum;
if ( glState.currenttextures[glState.currenttmu] != texnum ) {
image->frameUsed = tr.frameCount;
glState.currenttextures[glState.currenttmu] = texnum;
qglBindTexture (GL_TEXTURE_2D, texnum);
// VULKAN
glState.vk_current_images[glState.currenttmu] = final_image;
}
}

View File

@ -1853,6 +1853,10 @@ void R_DeleteTextures( void ) {
tr.numImages = 0;
Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) );
// VULKAN
Com_Memset( glState.vk_current_images, 0, sizeof( glState.vk_current_images ) );
if ( qglBindTexture ) {
GL_SelectTexture( 1 );
qglBindTexture( GL_TEXTURE_2D, 0 );

View File

@ -810,6 +810,9 @@ typedef struct {
int texEnv[2];
int faceCulling;
unsigned long glStateBits;
// VULKAN
image_t* vk_current_images[2];
} glstate_t;

View File

@ -856,17 +856,11 @@ void Vulkan_Demo::render_tess(const shaderStage_t* stage) {
vkCmdBindVertexBuffers(command_buffer, 0, 1, &tess_vertex_buffer, &tess_vertex_buffer_offset);
vkCmdBindIndexBuffer(command_buffer, tess_index_buffer, tess_index_buffer_offset, VK_INDEX_TYPE_UINT32);
VkDescriptorSet* set = &descriptor_set;
VkDescriptorSet image_set;
image_t* image = stage->bundle[0].image[0];
if (image != nullptr) {
image_set = image_descriptor_sets[image];
set = &image_set;
}
image_t* image = glState.vk_current_images[0];
VkDescriptorSet set = image_descriptor_sets[image];
update_uniform_buffer();
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, set, 1, &tess_ubo_offset);
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &set, 1, &tess_ubo_offset);
tess_ubo_offset += tess_ubo_offset_step;
VkViewport viewport;
@ -943,8 +937,8 @@ void Vulkan_Demo::render_tess_multi(const shaderStage_t* stage) {
vkCmdBindVertexBuffers(command_buffer, 0, 1, &tess_vertex_buffer, &tess_vertex_buffer_offset);
vkCmdBindIndexBuffer(command_buffer, tess_index_buffer, tess_index_buffer_offset, VK_INDEX_TYPE_UINT32);
image_t* image = stage->bundle[0].image[0];
image_t* image2 = stage->bundle[1].image[0];
image_t* image = glState.vk_current_images[0];
image_t* image2 = glState.vk_current_images[1];
auto images = std::make_pair(image, image2);
auto it = multitexture_descriptor_sets.find(images);
if (it == multitexture_descriptor_sets.cend()) {