mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 18:53:39 +00:00
wined3d: Use ARRAY_SIZE().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c11251c188
commit
7f8e30bd1a
|
@ -289,7 +289,7 @@ static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, G
|
|||
unsigned int i;
|
||||
|
||||
tex_type_str = NULL;
|
||||
for (i = 0; i < sizeof(texture_type) / sizeof(*texture_type); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
|
||||
{
|
||||
if (!gl_info->supported[texture_type[i].extension])
|
||||
continue;
|
||||
|
|
|
@ -2032,7 +2032,7 @@ void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device,
|
|||
if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
|
||||
sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
||||
|
||||
if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states))
|
||||
if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states))
|
||||
{
|
||||
WARN("Invalid sampler %u.\n", sampler_idx);
|
||||
return; /* Windows accepts overflowing this array ... we do not. */
|
||||
|
@ -2067,7 +2067,7 @@ DWORD CDECL wined3d_device_get_sampler_state(const struct wined3d_device *device
|
|||
if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
|
||||
sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
||||
|
||||
if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states))
|
||||
if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states))
|
||||
{
|
||||
WARN("Invalid sampler %u.\n", sampler_idx);
|
||||
return 0; /* Windows accepts overflowing this array ... we do not. */
|
||||
|
@ -3423,7 +3423,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
|
|||
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
||||
|
||||
/* Windows accepts overflowing this array... we do not. */
|
||||
if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures))
|
||||
if (stage >= ARRAY_SIZE(device->state.textures))
|
||||
{
|
||||
WARN("Ignoring invalid stage %u.\n", stage);
|
||||
return WINED3D_OK;
|
||||
|
@ -3467,7 +3467,7 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
|
|||
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
|
||||
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
||||
|
||||
if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures))
|
||||
if (stage >= ARRAY_SIZE(device->state.textures))
|
||||
{
|
||||
WARN("Ignoring invalid stage %u.\n", stage);
|
||||
return NULL; /* Windows accepts overflowing this array ... we do not. */
|
||||
|
|
|
@ -580,7 +580,7 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
|
|||
0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
|
||||
0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
|
||||
};
|
||||
unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
|
||||
unsigned int check[ARRAY_SIZE(pattern)];
|
||||
|
||||
/* No PBO -> No point in testing them. */
|
||||
if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
|
||||
|
@ -1525,7 +1525,7 @@ static const struct driver_version_information *get_driver_version_info(enum win
|
|||
unsigned int i;
|
||||
|
||||
TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
|
||||
for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i)
|
||||
{
|
||||
const struct driver_version_information *entry = &driver_version_table[i];
|
||||
|
||||
|
@ -1545,7 +1545,7 @@ static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i)
|
||||
{
|
||||
if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
|
||||
return &gpu_description_table[i];
|
||||
|
@ -1731,7 +1731,7 @@ static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_cap
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(quirk_table); ++i)
|
||||
{
|
||||
if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
|
||||
TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
|
||||
|
@ -2479,16 +2479,16 @@ static const struct
|
|||
card_vendor_table[] =
|
||||
{
|
||||
{HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
|
||||
sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table),
|
||||
ARRAY_SIZE(amd_gl_vendor_table),
|
||||
card_fallback_amd},
|
||||
{HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
|
||||
sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table),
|
||||
ARRAY_SIZE(nvidia_gl_vendor_table),
|
||||
card_fallback_nvidia},
|
||||
{HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table,
|
||||
sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table),
|
||||
ARRAY_SIZE(vmware_gl_vendor_table),
|
||||
card_fallback_amd},
|
||||
{HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
|
||||
sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table),
|
||||
ARRAY_SIZE(intel_gl_vendor_table),
|
||||
card_fallback_intel},
|
||||
};
|
||||
|
||||
|
@ -2550,7 +2550,7 @@ static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shad
|
|||
enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version);
|
||||
enum wined3d_pci_device device;
|
||||
|
||||
for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i)
|
||||
{
|
||||
if (card_vendor_table[i].card_vendor != *card_vendor)
|
||||
continue;
|
||||
|
@ -3975,13 +3975,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
|
|||
ERR("Received a NULL GL_EXTENSIONS.\n");
|
||||
return FALSE;
|
||||
}
|
||||
parse_extension_string(gl_info, gl_extensions, gl_extension_map,
|
||||
sizeof(gl_extension_map) / sizeof(*gl_extension_map));
|
||||
parse_extension_string(gl_info, gl_extensions, gl_extension_map, ARRAY_SIZE(gl_extension_map));
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerate_gl_extensions(gl_info, gl_extension_map,
|
||||
sizeof(gl_extension_map) / sizeof(*gl_extension_map));
|
||||
enumerate_gl_extensions(gl_info, gl_extension_map, ARRAY_SIZE(gl_extension_map));
|
||||
}
|
||||
|
||||
hdc = wglGetCurrentDC();
|
||||
|
@ -3991,8 +3989,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
|
|||
if (!WGL_Extensions)
|
||||
WARN("WGL extensions not supported.\n");
|
||||
else
|
||||
parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
|
||||
sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
|
||||
parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, ARRAY_SIZE(wgl_extension_map));
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
|
||||
{
|
||||
|
|
|
@ -1158,7 +1158,7 @@ static const struct wined3d_sm4_opcode_info *get_opcode_info(enum wined3d_sm4_op
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(opcode_table) / sizeof(*opcode_table); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(opcode_table); ++i)
|
||||
{
|
||||
if (opcode == opcode_table[i].opcode) return &opcode_table[i];
|
||||
}
|
||||
|
@ -1386,7 +1386,7 @@ static BOOL shader_sm4_read_param(struct wined3d_sm4_data *priv, const DWORD **p
|
|||
token = *(*ptr)++;
|
||||
|
||||
register_type = (token & WINED3D_SM4_REGISTER_TYPE_MASK) >> WINED3D_SM4_REGISTER_TYPE_SHIFT;
|
||||
if (register_type >= sizeof(register_type_table) / sizeof(*register_type_table)
|
||||
if (register_type >= ARRAY_SIZE(register_type_table)
|
||||
|| register_type_table[register_type] == ~0u)
|
||||
{
|
||||
FIXME("Unhandled register type %#x.\n", register_type);
|
||||
|
|
|
@ -6049,7 +6049,7 @@ static void validate_state_table(struct StateEntry *state_table)
|
|||
if (i == STATE_RENDER(rs_holes[current].last)) ++current;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(simple_states) / sizeof(*simple_states); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(simple_states); ++i)
|
||||
{
|
||||
if (!state_table[simple_states[i]].representative)
|
||||
ERR("State %s (%#x) should have a representative.\n",
|
||||
|
|
|
@ -237,16 +237,16 @@ static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states
|
|||
|
||||
states->pixelShader = 1;
|
||||
|
||||
for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
|
||||
{
|
||||
DWORD rs = pixel_states_render[i];
|
||||
states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(pixel_states_texture) / sizeof(*pixel_states_texture); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(pixel_states_texture); ++i)
|
||||
texture_mask |= 1u << pixel_states_texture[i];
|
||||
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
|
||||
for (i = 0; i < sizeof(pixel_states_sampler) / sizeof(*pixel_states_sampler); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(pixel_states_sampler); ++i)
|
||||
sampler_mask |= 1u << pixel_states_sampler[i];
|
||||
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
|
||||
states->pixelShaderConstantsB = 0xffff;
|
||||
|
@ -264,16 +264,16 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
|
|||
states->vertexDecl = 1;
|
||||
states->vertexShader = 1;
|
||||
|
||||
for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
|
||||
{
|
||||
DWORD rs = vertex_states_render[i];
|
||||
states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(vertex_states_texture) / sizeof(*vertex_states_texture); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(vertex_states_texture); ++i)
|
||||
texture_mask |= 1u << vertex_states_texture[i];
|
||||
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
|
||||
for (i = 0; i < sizeof(vertex_states_sampler) / sizeof(*vertex_states_sampler); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(vertex_states_sampler); ++i)
|
||||
sampler_mask |= 1u << vertex_states_sampler[i];
|
||||
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
|
||||
states->vertexShaderConstantsB = 0xffff;
|
||||
|
|
|
@ -1236,7 +1236,7 @@ static inline const struct d3dfmt_converter_desc *find_converter(enum wined3d_fo
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(converters) / sizeof(*converters)); ++i)
|
||||
for (i = 0; i < ARRAY_SIZE(converters); ++i)
|
||||
{
|
||||
if (converters[i].from == from && converters[i].to == to)
|
||||
return &converters[i];
|
||||
|
|
Loading…
Reference in a new issue