vkd3d-shader/fx: Do not align strings for fx_4/fx_5 profiles.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-02-06 14:21:46 +01:00 committed by Alexandre Julliard
parent d5f562d994
commit 656c068b32
Notes: Alexandre Julliard 2024-02-19 22:59:31 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/636
3 changed files with 10 additions and 3 deletions

View File

@ -145,7 +145,7 @@ static uint32_t write_fx_4_string(const char *string, struct fx_write_context *f
if (!(string_entry = hlsl_alloc(fx->ctx, sizeof(*string_entry)))) if (!(string_entry = hlsl_alloc(fx->ctx, sizeof(*string_entry))))
return 0; return 0;
string_entry->offset = put_string(&fx->unstructured, string); string_entry->offset = bytecode_put_bytes_unaligned(&fx->unstructured, string, strlen(string) + 1);
string_entry->string = string; string_entry->string = string;
rb_put(&fx->strings, string, &string_entry->entry); rb_put(&fx->strings, string, &string_entry->entry);

View File

@ -366,9 +366,9 @@ size_t bytecode_align(struct vkd3d_bytecode_buffer *buffer)
return aligned_size; return aligned_size;
} }
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size) size_t bytecode_put_bytes_unaligned(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
{ {
size_t offset = bytecode_align(buffer); size_t offset = buffer->size;
if (buffer->status) if (buffer->status)
return offset; return offset;
@ -383,6 +383,12 @@ size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *byte
return offset; return offset;
} }
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
{
bytecode_align(buffer);
return bytecode_put_bytes_unaligned(buffer, bytes, size);
}
size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size) size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size)
{ {
size_t offset = bytecode_align(buffer); size_t offset = bytecode_align(buffer);

View File

@ -1418,6 +1418,7 @@ struct vkd3d_bytecode_buffer
/* Align to the next 4-byte offset, and return that offset. */ /* Align to the next 4-byte offset, and return that offset. */
size_t bytecode_align(struct vkd3d_bytecode_buffer *buffer); size_t bytecode_align(struct vkd3d_bytecode_buffer *buffer);
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size); size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size);
size_t bytecode_put_bytes_unaligned(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size);
size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size); size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size);
void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value); void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value);
void set_string(struct vkd3d_bytecode_buffer *buffer, size_t offset, const char *string, size_t length); void set_string(struct vkd3d_bytecode_buffer *buffer, size_t offset, const char *string, size_t length);